You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ki...@apache.org on 2019/06/12 20:21:12 UTC

[incubator-pinot] branch master updated: PQL -> SQL enhancement - phase 1 - new Pinot Query Struct (#4216)

This is an automated email from the ASF dual-hosted git repository.

kishoreg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 9f3fe4e  PQL -> SQL enhancement - phase 1 - new Pinot Query Struct (#4216)
9f3fe4e is described below

commit 9f3fe4e4ac42db2a39115cc4fe9a4ed7cd7599b1
Author: Xiang Fu <fx...@gmail.com>
AuthorDate: Wed Jun 12 13:21:05 2019 -0700

    PQL -> SQL enhancement - phase 1 - new Pinot Query Struct (#4216)
    
    * Adding query.thrift - enhancing broker request (#15)
    
    * Adding pinot query to broker request converter (#16)
    
    * Adding pinot query to broker request converter
    
    * Addressing review comments and fixing bug in handling filter expression
    
    * Adding license header
    
    * Adding AST parser to PinotQuery insider BrokerRequest (#17)
    
    * Adding AST parser to PinotQuery insider BrokerRequest
    
    * Fixing Predicate implementation
    
    * Make filter expression in PinotQuery use calcite function names in SqlKind (#20)
    
    * Adding more filter operators into FilterKind (#21)
    
    * Adding validation mode to compare broker request and pinot query (#19)
    
    * Adding validation mode to compare broker request and pinot query
    
    * Fixing the logic to assign ids to sub filter in the current code
    
    * Logging PQL when conversion fails
    
    * Adding SelectionSort and make standardizeExpression to take one more paramter to single quote non-string literal inside functions
    
    * ignore test of having queries
    
    * Minor clean. Warning on mismatch instead of throwing exception
    
    * Adding license header
    
    * Addressing review comments
    
    * not format thrift auto-gen code
    
    * rebase
    
    * address comments
    
    * addressing review comments
    
    * Addressing review comments and disabling creation of pinot query by default
    
    * Pulling some changes that were missed in this PR. Test case passes now
    
    * Removing InstanceRequestV2 class file and adding license headers
    
    * Moving all tests with pinot query in testConverter method
    
    * Deduping In predicate values and adding test case
---
 pinot-common/pom.xml                               |    7 +
 .../pinot/common/request/AggregationInfo.java      |    6 +-
 .../apache/pinot/common/request/BrokerRequest.java |  133 +-
 .../request/{QuerySource.java => DataSource.java}  |   61 +-
 .../apache/pinot/common/request/Expression.java    |  774 +++++++++
 .../{FilterOperator.java => ExpressionType.java}   |   31 +-
 .../pinot/common/request/FilterOperator.java       |    2 +-
 .../apache/pinot/common/request/FilterQuery.java   |    6 +-
 .../pinot/common/request/FilterQueryMap.java       |    4 +-
 .../Function.java}                                 |  365 ++--
 .../org/apache/pinot/common/request/GroupBy.java   |   70 +-
 .../pinot/common/request/HavingFilterQuery.java    |    6 +-
 .../pinot/common/request/HavingFilterQueryMap.java |    4 +-
 .../request/{QuerySource.java => Identifier.java}  |  200 +--
 .../pinot/common/request/InstanceRequest.java      |   40 +-
 .../org/apache/pinot/common/request/Literal.java   |  771 +++++++++
 .../apache/pinot/common/request/PinotQuery.java    | 1807 ++++++++++++++++++++
 .../apache/pinot/common/request/QuerySource.java   |    4 +-
 .../org/apache/pinot/common/request/QueryType.java |   14 +-
 .../org/apache/pinot/common/request/Selection.java |   76 +-
 .../apache/pinot/common/request/SelectionSort.java |    6 +-
 .../pinot/common/response/ProcessingException.java |    6 +-
 .../pinot/common/utils/request/RequestUtils.java   |   99 +-
 .../parsers/PinotQuery2BrokerRequestConverter.java |  354 ++++
 .../org/apache/pinot/pql/parsers/Pql2Compiler.java |   98 +-
 .../apache/pinot/pql/parsers/pql2/ast/AstNode.java |    5 +
 .../pinot/pql/parsers/pql2/ast/BaseAstNode.java    |   14 +
 .../parsers/pql2/ast/BetweenPredicateAstNode.java  |   31 +-
 .../parsers/pql2/ast/BooleanOperatorAstNode.java   |   10 +
 .../pql2/ast/ComparisonPredicateAstNode.java       |   70 +
 .../ast/{OptionsAstNode.java => FilterKind.java}   |   29 +-
 .../pinot/pql/parsers/pql2/ast/GroupByAstNode.java |   14 +
 .../pinot/pql/parsers/pql2/ast/HavingAstNode.java  |    5 +
 .../pql/parsers/pql2/ast/InPredicateAstNode.java   |   35 +-
 .../pinot/pql/parsers/pql2/ast/OptionAstNode.java  |   30 +
 .../pinot/pql/parsers/pql2/ast/OptionsAstNode.java |   10 +-
 .../pinot/pql/parsers/pql2/ast/OrderByAstNode.java |   24 +
 .../pql/parsers/pql2/ast/OutputColumnAstNode.java  |   27 +
 .../parsers/pql2/ast/OutputColumnListAstNode.java  |    6 +
 .../pql/parsers/pql2/ast/PredicateAstNode.java     |    9 +-
 .../pql/parsers/pql2/ast/PredicateListAstNode.java |   67 +-
 .../pql2/ast/PredicateParenthesisGroupAstNode.java |    6 +
 .../pql2/ast/RegexpLikePredicateAstNode.java       |   18 +
 .../pinot/pql/parsers/pql2/ast/SelectAstNode.java  |   31 +
 .../parsers/pql2/ast/StarColumnListAstNode.java    |    9 +
 .../pinot/pql/parsers/pql2/ast/WhereAstNode.java   |    7 +
 .../apache/pinot/pql/parsers/Pql2CompilerTest.java |  184 +-
 .../request/BrokerRequestSerializationTest.java    |  143 ++
 pinot-common/src/test/resources/pql_queries.list   |  814 +++++++++
 pinot-common/src/thrift/query.thrift               |   70 +
 pinot-common/src/thrift/request.thrift             |    2 +
 .../core/query/reduce/InAndNotInComparison.java    |    1 +
 .../pinot/reduce/HavingClauseComparisonTests.java  |    1 -
 53 files changed, 6137 insertions(+), 479 deletions(-)

diff --git a/pinot-common/pom.xml b/pinot-common/pom.xml
index 624da84..410e06e 100644
--- a/pinot-common/pom.xml
+++ b/pinot-common/pom.xml
@@ -358,6 +358,13 @@
                       <arg value="java:beans"/>
                       <arg value="-o"/>
                       <arg value="target/generated-sources"/>
+                      <arg value="src/thrift/query.thrift"/>
+                    </exec>
+                    <exec executable="/usr/local/bin/thrift">
+                      <arg value="--gen"/>
+                      <arg value="java:beans"/>
+                      <arg value="-o"/>
+                      <arg value="target/generated-sources"/>
                       <arg value="src/thrift/request.thrift"/>
                     </exec>
                     <exec executable="/usr/local/bin/thrift">
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/AggregationInfo.java b/pinot-common/src/main/java/org/apache/pinot/common/request/AggregationInfo.java
index 6508b14..99fcc72 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/AggregationInfo.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/AggregationInfo.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -47,7 +47,7 @@ import org.apache.thrift.scheme.TupleScheme;
  *  Aggregation
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-8-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class AggregationInfo implements org.apache.thrift.TBase<AggregationInfo, AggregationInfo._Fields>, java.io.Serializable, Cloneable, Comparable<AggregationInfo> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("AggregationInfo");
@@ -308,7 +308,7 @@ public class AggregationInfo implements org.apache.thrift.TBase<AggregationInfo,
         return getAggregationParams();
 
       case IS_IN_SELECT_LIST:
-        return Boolean.valueOf(isIsInSelectList());
+        return isIsInSelectList();
     }
     throw new IllegalStateException();
   }
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/BrokerRequest.java b/pinot-common/src/main/java/org/apache/pinot/common/request/BrokerRequest.java
index c9925de..9a25d6e 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/BrokerRequest.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/BrokerRequest.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -47,7 +47,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * Broker Query
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-8-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, BrokerRequest._Fields>, java.io.Serializable, Cloneable, Comparable<BrokerRequest> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("BrokerRequest");
@@ -85,6 +85,8 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
   private static final org.apache.thrift.protocol.TField HAVING_FILTER_SUB_QUERY_MAP_FIELD_DESC =
       new org.apache.thrift.protocol.TField("havingFilterSubQueryMap", org.apache.thrift.protocol.TType.STRUCT,
           (short) 16);
+  private static final org.apache.thrift.protocol.TField PINOT_QUERY_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("pinotQuery", org.apache.thrift.protocol.TType.STRUCT, (short) 17);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes =
       new HashMap<Class<? extends IScheme>, SchemeFactory>();
@@ -110,6 +112,7 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
   private Map<String, String> queryOptions; // optional
   private HavingFilterQuery havingFilterQuery; // optional
   private HavingFilterQueryMap havingFilterSubQueryMap; // optional
+  private org.apache.pinot.common.request.PinotQuery pinotQuery; // optional
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@@ -128,7 +131,8 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
     DEBUG_OPTIONS((short) 13, "debugOptions"),
     QUERY_OPTIONS((short) 14, "queryOptions"),
     HAVING_FILTER_QUERY((short) 15, "havingFilterQuery"),
-    HAVING_FILTER_SUB_QUERY_MAP((short) 16, "havingFilterSubQueryMap");
+    HAVING_FILTER_SUB_QUERY_MAP((short) 16, "havingFilterSubQueryMap"),
+    PINOT_QUERY((short) 17, "pinotQuery");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -175,6 +179,8 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
           return HAVING_FILTER_QUERY;
         case 16: // HAVING_FILTER_SUB_QUERY_MAP
           return HAVING_FILTER_SUB_QUERY_MAP;
+        case 17: // PINOT_QUERY
+          return PINOT_QUERY;
         default:
           return null;
       }
@@ -220,7 +226,7 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
   private static final int __ENABLETRACE_ISSET_ID = 0;
   private byte __isset_bitfield = 0;
   private static final _Fields optionals[] =
-      {_Fields.QUERY_TYPE, _Fields.QUERY_SOURCE, _Fields.TIME_INTERVAL, _Fields.DURATION, _Fields.FILTER_QUERY, _Fields.AGGREGATIONS_INFO, _Fields.GROUP_BY, _Fields.SELECTIONS, _Fields.FILTER_SUB_QUERY_MAP, _Fields.BUCKET_HASH_KEY, _Fields.ENABLE_TRACE, _Fields.RESPONSE_FORMAT, _Fields.DEBUG_OPTIONS, _Fields.QUERY_OPTIONS, _Fields.HAVING_FILTER_QUERY, _Fields.HAVING_FILTER_SUB_QUERY_MAP};
+      {_Fields.QUERY_TYPE, _Fields.QUERY_SOURCE, _Fields.TIME_INTERVAL, _Fields.DURATION, _Fields.FILTER_QUERY, _Fields.AGGREGATIONS_INFO, _Fields.GROUP_BY, _Fields.SELECTIONS, _Fields.FILTER_SUB_QUERY_MAP, _Fields.BUCKET_HASH_KEY, _Fields.ENABLE_TRACE, _Fields.RESPONSE_FORMAT, _Fields.DEBUG_OPTIONS, _Fields.QUERY_OPTIONS, _Fields.HAVING_FILTER_QUERY, _Fields.HAVING_FILTER_SUB_QUERY_MAP, _Fields.PINOT_QUERY};
   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
 
   static {
@@ -285,6 +291,10 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
             org.apache.thrift.TFieldRequirementType.OPTIONAL,
             new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                 HavingFilterQueryMap.class)));
+    tmpMap.put(_Fields.PINOT_QUERY,
+        new org.apache.thrift.meta_data.FieldMetaData("pinotQuery", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
+                org.apache.pinot.common.request.PinotQuery.class)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(BrokerRequest.class, metaDataMap);
   }
@@ -349,6 +359,9 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
     if (other.isSetHavingFilterSubQueryMap()) {
       this.havingFilterSubQueryMap = new HavingFilterQueryMap(other.havingFilterSubQueryMap);
     }
+    if (other.isSetPinotQuery()) {
+      this.pinotQuery = new org.apache.pinot.common.request.PinotQuery(other.pinotQuery);
+    }
   }
 
   public BrokerRequest deepCopy() {
@@ -374,6 +387,7 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
     this.queryOptions = null;
     this.havingFilterQuery = null;
     this.havingFilterSubQueryMap = null;
+    this.pinotQuery = null;
   }
 
   public QueryType getQueryType() {
@@ -780,6 +794,29 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
     }
   }
 
+  public org.apache.pinot.common.request.PinotQuery getPinotQuery() {
+    return this.pinotQuery;
+  }
+
+  public void setPinotQuery(org.apache.pinot.common.request.PinotQuery pinotQuery) {
+    this.pinotQuery = pinotQuery;
+  }
+
+  public void unsetPinotQuery() {
+    this.pinotQuery = null;
+  }
+
+  /** Returns true if field pinotQuery is set (has been assigned a value) and false otherwise */
+  public boolean isSetPinotQuery() {
+    return this.pinotQuery != null;
+  }
+
+  public void setPinotQueryIsSet(boolean value) {
+    if (!value) {
+      this.pinotQuery = null;
+    }
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
       case QUERY_TYPE:
@@ -909,6 +946,14 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
           setHavingFilterSubQueryMap((HavingFilterQueryMap) value);
         }
         break;
+
+      case PINOT_QUERY:
+        if (value == null) {
+          unsetPinotQuery();
+        } else {
+          setPinotQuery((org.apache.pinot.common.request.PinotQuery) value);
+        }
+        break;
     }
   }
 
@@ -945,7 +990,7 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
         return getBucketHashKey();
 
       case ENABLE_TRACE:
-        return Boolean.valueOf(isEnableTrace());
+        return isEnableTrace();
 
       case RESPONSE_FORMAT:
         return getResponseFormat();
@@ -961,6 +1006,9 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
 
       case HAVING_FILTER_SUB_QUERY_MAP:
         return getHavingFilterSubQueryMap();
+
+      case PINOT_QUERY:
+        return getPinotQuery();
     }
     throw new IllegalStateException();
   }
@@ -1004,6 +1052,8 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
         return isSetHavingFilterQuery();
       case HAVING_FILTER_SUB_QUERY_MAP:
         return isSetHavingFilterSubQueryMap();
+      case PINOT_QUERY:
+        return isSetPinotQuery();
     }
     throw new IllegalStateException();
   }
@@ -1200,6 +1250,17 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
       }
     }
 
+    boolean this_present_pinotQuery = true && this.isSetPinotQuery();
+    boolean that_present_pinotQuery = true && that.isSetPinotQuery();
+    if (this_present_pinotQuery || that_present_pinotQuery) {
+      if (!(this_present_pinotQuery && that_present_pinotQuery)) {
+        return false;
+      }
+      if (!this.pinotQuery.equals(that.pinotQuery)) {
+        return false;
+      }
+    }
+
     return true;
   }
 
@@ -1303,6 +1364,12 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
       list.add(havingFilterSubQueryMap);
     }
 
+    boolean present_pinotQuery = true && (isSetPinotQuery());
+    list.add(present_pinotQuery);
+    if (present_pinotQuery) {
+      list.add(pinotQuery);
+    }
+
     return list.hashCode();
   }
 
@@ -1475,6 +1542,16 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetPinotQuery()).compareTo(other.isSetPinotQuery());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetPinotQuery()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pinotQuery, other.pinotQuery);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -1682,6 +1759,18 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
       }
       first = false;
     }
+    if (isSetPinotQuery()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("pinotQuery:");
+      if (this.pinotQuery == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.pinotQuery);
+      }
+      first = false;
+    }
     sb.append(")");
     return sb.toString();
   }
@@ -1714,6 +1803,9 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
     if (havingFilterSubQueryMap != null) {
       havingFilterSubQueryMap.validate();
     }
+    if (pinotQuery != null) {
+      pinotQuery.validate();
+    }
   }
 
   private void writeObject(java.io.ObjectOutputStream out)
@@ -1922,6 +2014,15 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
+          case 17: // PINOT_QUERY
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.pinotQuery = new org.apache.pinot.common.request.PinotQuery();
+              struct.pinotQuery.read(iprot);
+              struct.setPinotQueryIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
           default:
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
         }
@@ -2069,6 +2170,13 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
           oprot.writeFieldEnd();
         }
       }
+      if (struct.pinotQuery != null) {
+        if (struct.isSetPinotQuery()) {
+          oprot.writeFieldBegin(PINOT_QUERY_FIELD_DESC);
+          struct.pinotQuery.write(oprot);
+          oprot.writeFieldEnd();
+        }
+      }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
     }
@@ -2135,7 +2243,10 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
       if (struct.isSetHavingFilterSubQueryMap()) {
         optionals.set(15);
       }
-      oprot.writeBitSet(optionals, 16);
+      if (struct.isSetPinotQuery()) {
+        optionals.set(16);
+      }
+      oprot.writeBitSet(optionals, 17);
       if (struct.isSetQueryType()) {
         struct.queryType.write(oprot);
       }
@@ -2201,13 +2312,16 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
       if (struct.isSetHavingFilterSubQueryMap()) {
         struct.havingFilterSubQueryMap.write(oprot);
       }
+      if (struct.isSetPinotQuery()) {
+        struct.pinotQuery.write(oprot);
+      }
     }
 
     @Override
     public void read(org.apache.thrift.protocol.TProtocol prot, BrokerRequest struct)
         throws org.apache.thrift.TException {
       TTupleProtocol iprot = (TTupleProtocol) prot;
-      BitSet incoming = iprot.readBitSet(16);
+      BitSet incoming = iprot.readBitSet(17);
       if (incoming.get(0)) {
         struct.queryType = new QueryType();
         struct.queryType.read(iprot);
@@ -2314,6 +2428,11 @@ public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, Bro
         struct.havingFilterSubQueryMap.read(iprot);
         struct.setHavingFilterSubQueryMapIsSet(true);
       }
+      if (incoming.get(16)) {
+        struct.pinotQuery = new org.apache.pinot.common.request.PinotQuery();
+        struct.pinotQuery.read(iprot);
+        struct.setPinotQueryIsSet(true);
+      }
     }
   }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java b/pinot-common/src/main/java/org/apache/pinot/common/request/DataSource.java
similarity index 87%
copy from pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java
copy to pinot-common/src/main/java/org/apache/pinot/common/request/DataSource.java
index ab4b6d4..d43ce73 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/DataSource.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -41,15 +41,10 @@ import org.apache.thrift.scheme.TupleScheme;
 
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-/**
- * AUTO GENERATED: DO NOT EDIT
- * Query source
- *
- */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
-public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySource._Fields>, java.io.Serializable, Cloneable, Comparable<QuerySource> {
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
+public class DataSource implements org.apache.thrift.TBase<DataSource, DataSource._Fields>, java.io.Serializable, Cloneable, Comparable<DataSource> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
-      new org.apache.thrift.protocol.TStruct("QuerySource");
+      new org.apache.thrift.protocol.TStruct("DataSource");
 
   private static final org.apache.thrift.protocol.TField TABLE_NAME_FIELD_DESC =
       new org.apache.thrift.protocol.TField("tableName", org.apache.thrift.protocol.TType.STRING, (short) 1);
@@ -58,8 +53,8 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
       new HashMap<Class<? extends IScheme>, SchemeFactory>();
 
   static {
-    schemes.put(StandardScheme.class, new QuerySourceStandardSchemeFactory());
-    schemes.put(TupleScheme.class, new QuerySourceTupleSchemeFactory());
+    schemes.put(StandardScheme.class, new DataSourceStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new DataSourceTupleSchemeFactory());
   }
 
   private String tableName; // optional
@@ -135,23 +130,23 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
         new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(QuerySource.class, metaDataMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(DataSource.class, metaDataMap);
   }
 
-  public QuerySource() {
+  public DataSource() {
   }
 
   /**
    * Performs a deep copy on <i>other</i>.
    */
-  public QuerySource(QuerySource other) {
+  public DataSource(DataSource other) {
     if (other.isSetTableName()) {
       this.tableName = other.tableName;
     }
   }
 
-  public QuerySource deepCopy() {
-    return new QuerySource(this);
+  public DataSource deepCopy() {
+    return new DataSource(this);
   }
 
   @Override
@@ -220,13 +215,13 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
     if (that == null) {
       return false;
     }
-    if (that instanceof QuerySource) {
-      return this.equals((QuerySource) that);
+    if (that instanceof DataSource) {
+      return this.equals((DataSource) that);
     }
     return false;
   }
 
-  public boolean equals(QuerySource that) {
+  public boolean equals(DataSource that) {
     if (that == null) {
       return false;
     }
@@ -259,7 +254,7 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
   }
 
   @Override
-  public int compareTo(QuerySource other) {
+  public int compareTo(DataSource other) {
     if (!getClass().equals(other.getClass())) {
       return getClass().getName().compareTo(other.getClass().getName());
     }
@@ -295,7 +290,7 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder("QuerySource(");
+    StringBuilder sb = new StringBuilder("DataSource(");
     boolean first = true;
 
     if (isSetTableName()) {
@@ -335,15 +330,15 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
     }
   }
 
-  private static class QuerySourceStandardSchemeFactory implements SchemeFactory {
-    public QuerySourceStandardScheme getScheme() {
-      return new QuerySourceStandardScheme();
+  private static class DataSourceStandardSchemeFactory implements SchemeFactory {
+    public DataSourceStandardScheme getScheme() {
+      return new DataSourceStandardScheme();
     }
   }
 
-  private static class QuerySourceStandardScheme extends StandardScheme<QuerySource> {
+  private static class DataSourceStandardScheme extends StandardScheme<DataSource> {
 
-    public void read(org.apache.thrift.protocol.TProtocol iprot, QuerySource struct)
+    public void read(org.apache.thrift.protocol.TProtocol iprot, DataSource struct)
         throws org.apache.thrift.TException {
       org.apache.thrift.protocol.TField schemeField;
       iprot.readStructBegin();
@@ -370,7 +365,7 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
       struct.validate();
     }
 
-    public void write(org.apache.thrift.protocol.TProtocol oprot, QuerySource struct)
+    public void write(org.apache.thrift.protocol.TProtocol oprot, DataSource struct)
         throws org.apache.thrift.TException {
       struct.validate();
 
@@ -387,16 +382,16 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
     }
   }
 
-  private static class QuerySourceTupleSchemeFactory implements SchemeFactory {
-    public QuerySourceTupleScheme getScheme() {
-      return new QuerySourceTupleScheme();
+  private static class DataSourceTupleSchemeFactory implements SchemeFactory {
+    public DataSourceTupleScheme getScheme() {
+      return new DataSourceTupleScheme();
     }
   }
 
-  private static class QuerySourceTupleScheme extends TupleScheme<QuerySource> {
+  private static class DataSourceTupleScheme extends TupleScheme<DataSource> {
 
     @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, QuerySource struct)
+    public void write(org.apache.thrift.protocol.TProtocol prot, DataSource struct)
         throws org.apache.thrift.TException {
       TTupleProtocol oprot = (TTupleProtocol) prot;
       BitSet optionals = new BitSet();
@@ -410,7 +405,7 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
     }
 
     @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, QuerySource struct)
+    public void read(org.apache.thrift.protocol.TProtocol prot, DataSource struct)
         throws org.apache.thrift.TException {
       TTupleProtocol iprot = (TTupleProtocol) prot;
       BitSet incoming = iprot.readBitSet(1);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/Expression.java b/pinot-common/src/main/java/org/apache/pinot/common/request/Expression.java
new file mode 100644
index 0000000..43cae1d
--- /dev/null
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/Expression.java
@@ -0,0 +1,774 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Autogenerated by Thrift Compiler (0.9.3)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.pinot.common.request;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Generated;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+import org.apache.thrift.scheme.TupleScheme;
+
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
+public class Expression implements org.apache.thrift.TBase<Expression, Expression._Fields>, java.io.Serializable, Cloneable, Comparable<Expression> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
+      new org.apache.thrift.protocol.TStruct("Expression");
+
+  private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.I32, (short) 1);
+  private static final org.apache.thrift.protocol.TField FUNCTION_CALL_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("functionCall", org.apache.thrift.protocol.TType.STRUCT, (short) 2);
+  private static final org.apache.thrift.protocol.TField LITERAL_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("literal", org.apache.thrift.protocol.TType.STRUCT, (short) 3);
+  private static final org.apache.thrift.protocol.TField IDENTIFIER_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("identifier", org.apache.thrift.protocol.TType.STRUCT, (short) 4);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes =
+      new HashMap<Class<? extends IScheme>, SchemeFactory>();
+
+  static {
+    schemes.put(StandardScheme.class, new ExpressionStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new ExpressionTupleSchemeFactory());
+  }
+
+  private ExpressionType type; // required
+  private Function functionCall; // optional
+  private Literal literal; // optional
+  private Identifier identifier; // optional
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    /**
+     *
+     * @see ExpressionType
+     */
+    TYPE((short) 1, "type"),
+    FUNCTION_CALL((short) 2, "functionCall"),
+    LITERAL((short) 3, "literal"),
+    IDENTIFIER((short) 4, "identifier");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch (fieldId) {
+        case 1: // TYPE
+          return TYPE;
+        case 2: // FUNCTION_CALL
+          return FUNCTION_CALL;
+        case 3: // LITERAL
+          return LITERAL;
+        case 4: // IDENTIFIER
+          return IDENTIFIER;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) {
+        throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      }
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+
+  // isset id assignments
+  private static final _Fields optionals[] = {_Fields.FUNCTION_CALL, _Fields.LITERAL, _Fields.IDENTIFIER};
+  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+
+  static {
+    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap =
+        new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.TYPE,
+        new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED,
+            new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, ExpressionType.class)));
+    tmpMap.put(_Fields.FUNCTION_CALL,
+        new org.apache.thrift.meta_data.FieldMetaData("functionCall", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT, "Function")));
+    tmpMap.put(_Fields.LITERAL,
+        new org.apache.thrift.meta_data.FieldMetaData("literal", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT, "Literal")));
+    tmpMap.put(_Fields.IDENTIFIER,
+        new org.apache.thrift.meta_data.FieldMetaData("identifier", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT, "Identifier")));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Expression.class, metaDataMap);
+  }
+
+  public Expression() {
+  }
+
+  public Expression(ExpressionType type) {
+    this();
+    this.type = type;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public Expression(Expression other) {
+    if (other.isSetType()) {
+      this.type = other.type;
+    }
+    if (other.isSetFunctionCall()) {
+      this.functionCall = other.functionCall;
+    }
+    if (other.isSetLiteral()) {
+      this.literal = other.literal;
+    }
+    if (other.isSetIdentifier()) {
+      this.identifier = other.identifier;
+    }
+  }
+
+  public Expression deepCopy() {
+    return new Expression(this);
+  }
+
+  @Override
+  public void clear() {
+    this.type = null;
+    this.functionCall = null;
+    this.literal = null;
+    this.identifier = null;
+  }
+
+  /**
+   *
+   * @see ExpressionType
+   */
+  public ExpressionType getType() {
+    return this.type;
+  }
+
+  /**
+   *
+   * @see ExpressionType
+   */
+  public void setType(ExpressionType type) {
+    this.type = type;
+  }
+
+  public void unsetType() {
+    this.type = null;
+  }
+
+  /** Returns true if field type is set (has been assigned a value) and false otherwise */
+  public boolean isSetType() {
+    return this.type != null;
+  }
+
+  public void setTypeIsSet(boolean value) {
+    if (!value) {
+      this.type = null;
+    }
+  }
+
+  public Function getFunctionCall() {
+    return this.functionCall;
+  }
+
+  public void setFunctionCall(Function functionCall) {
+    this.functionCall = functionCall;
+  }
+
+  public void unsetFunctionCall() {
+    this.functionCall = null;
+  }
+
+  /** Returns true if field functionCall is set (has been assigned a value) and false otherwise */
+  public boolean isSetFunctionCall() {
+    return this.functionCall != null;
+  }
+
+  public void setFunctionCallIsSet(boolean value) {
+    if (!value) {
+      this.functionCall = null;
+    }
+  }
+
+  public Literal getLiteral() {
+    return this.literal;
+  }
+
+  public void setLiteral(Literal literal) {
+    this.literal = literal;
+  }
+
+  public void unsetLiteral() {
+    this.literal = null;
+  }
+
+  /** Returns true if field literal is set (has been assigned a value) and false otherwise */
+  public boolean isSetLiteral() {
+    return this.literal != null;
+  }
+
+  public void setLiteralIsSet(boolean value) {
+    if (!value) {
+      this.literal = null;
+    }
+  }
+
+  public Identifier getIdentifier() {
+    return this.identifier;
+  }
+
+  public void setIdentifier(Identifier identifier) {
+    this.identifier = identifier;
+  }
+
+  public void unsetIdentifier() {
+    this.identifier = null;
+  }
+
+  /** Returns true if field identifier is set (has been assigned a value) and false otherwise */
+  public boolean isSetIdentifier() {
+    return this.identifier != null;
+  }
+
+  public void setIdentifierIsSet(boolean value) {
+    if (!value) {
+      this.identifier = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+      case TYPE:
+        if (value == null) {
+          unsetType();
+        } else {
+          setType((ExpressionType) value);
+        }
+        break;
+
+      case FUNCTION_CALL:
+        if (value == null) {
+          unsetFunctionCall();
+        } else {
+          setFunctionCall((Function) value);
+        }
+        break;
+
+      case LITERAL:
+        if (value == null) {
+          unsetLiteral();
+        } else {
+          setLiteral((Literal) value);
+        }
+        break;
+
+      case IDENTIFIER:
+        if (value == null) {
+          unsetIdentifier();
+        } else {
+          setIdentifier((Identifier) value);
+        }
+        break;
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+      case TYPE:
+        return getType();
+
+      case FUNCTION_CALL:
+        return getFunctionCall();
+
+      case LITERAL:
+        return getLiteral();
+
+      case IDENTIFIER:
+        return getIdentifier();
+    }
+    throw new IllegalStateException();
+  }
+
+  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
+      case TYPE:
+        return isSetType();
+      case FUNCTION_CALL:
+        return isSetFunctionCall();
+      case LITERAL:
+        return isSetLiteral();
+      case IDENTIFIER:
+        return isSetIdentifier();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null) {
+      return false;
+    }
+    if (that instanceof Expression) {
+      return this.equals((Expression) that);
+    }
+    return false;
+  }
+
+  public boolean equals(Expression that) {
+    if (that == null) {
+      return false;
+    }
+
+    boolean this_present_type = true && this.isSetType();
+    boolean that_present_type = true && that.isSetType();
+    if (this_present_type || that_present_type) {
+      if (!(this_present_type && that_present_type)) {
+        return false;
+      }
+      if (!this.type.equals(that.type)) {
+        return false;
+      }
+    }
+
+    boolean this_present_functionCall = true && this.isSetFunctionCall();
+    boolean that_present_functionCall = true && that.isSetFunctionCall();
+    if (this_present_functionCall || that_present_functionCall) {
+      if (!(this_present_functionCall && that_present_functionCall)) {
+        return false;
+      }
+      if (!this.functionCall.equals(that.functionCall)) {
+        return false;
+      }
+    }
+
+    boolean this_present_literal = true && this.isSetLiteral();
+    boolean that_present_literal = true && that.isSetLiteral();
+    if (this_present_literal || that_present_literal) {
+      if (!(this_present_literal && that_present_literal)) {
+        return false;
+      }
+      if (!this.literal.equals(that.literal)) {
+        return false;
+      }
+    }
+
+    boolean this_present_identifier = true && this.isSetIdentifier();
+    boolean that_present_identifier = true && that.isSetIdentifier();
+    if (this_present_identifier || that_present_identifier) {
+      if (!(this_present_identifier && that_present_identifier)) {
+        return false;
+      }
+      if (!this.identifier.equals(that.identifier)) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    List<Object> list = new ArrayList<Object>();
+
+    boolean present_type = true && (isSetType());
+    list.add(present_type);
+    if (present_type) {
+      list.add(type.getValue());
+    }
+
+    boolean present_functionCall = true && (isSetFunctionCall());
+    list.add(present_functionCall);
+    if (present_functionCall) {
+      list.add(functionCall);
+    }
+
+    boolean present_literal = true && (isSetLiteral());
+    list.add(present_literal);
+    if (present_literal) {
+      list.add(literal);
+    }
+
+    boolean present_identifier = true && (isSetIdentifier());
+    list.add(present_identifier);
+    if (present_identifier) {
+      list.add(identifier);
+    }
+
+    return list.hashCode();
+  }
+
+  @Override
+  public int compareTo(Expression other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetType()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetFunctionCall()).compareTo(other.isSetFunctionCall());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetFunctionCall()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.functionCall, other.functionCall);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetLiteral()).compareTo(other.isSetLiteral());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetLiteral()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.literal, other.literal);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetIdentifier()).compareTo(other.isSetIdentifier());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetIdentifier()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.identifier, other.identifier);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot)
+      throws org.apache.thrift.TException {
+    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot)
+      throws org.apache.thrift.TException {
+    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("Expression(");
+    boolean first = true;
+
+    sb.append("type:");
+    if (this.type == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.type);
+    }
+    first = false;
+    if (isSetFunctionCall()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("functionCall:");
+      if (this.functionCall == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.functionCall);
+      }
+      first = false;
+    }
+    if (isSetLiteral()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("literal:");
+      if (this.literal == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.literal);
+      }
+      first = false;
+    }
+    if (isSetIdentifier()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("identifier:");
+      if (this.identifier == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.identifier);
+      }
+      first = false;
+    }
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate()
+      throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetType()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' is unset! Struct:" + toString());
+    }
+
+    // check for sub-struct validity
+  }
+
+  private void writeObject(java.io.ObjectOutputStream out)
+      throws java.io.IOException {
+    try {
+      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private void readObject(java.io.ObjectInputStream in)
+      throws java.io.IOException, ClassNotFoundException {
+    try {
+      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private static class ExpressionStandardSchemeFactory implements SchemeFactory {
+    public ExpressionStandardScheme getScheme() {
+      return new ExpressionStandardScheme();
+    }
+  }
+
+  private static class ExpressionStandardScheme extends StandardScheme<Expression> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, Expression struct)
+        throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TField schemeField;
+      iprot.readStructBegin();
+      while (true) {
+        schemeField = iprot.readFieldBegin();
+        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+          break;
+        }
+        switch (schemeField.id) {
+          case 1: // TYPE
+            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+              struct.type = org.apache.pinot.common.request.ExpressionType.findByValue(iprot.readI32());
+              struct.setTypeIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // FUNCTION_CALL
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.functionCall = new Function();
+              struct.functionCall.read(iprot);
+              struct.setFunctionCallIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 3: // LITERAL
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.literal = new Literal();
+              struct.literal.read(iprot);
+              struct.setLiteralIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 4: // IDENTIFIER
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.identifier = new Identifier();
+              struct.identifier.read(iprot);
+              struct.setIdentifierIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          default:
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+        }
+        iprot.readFieldEnd();
+      }
+      iprot.readStructEnd();
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, Expression struct)
+        throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.type != null) {
+        oprot.writeFieldBegin(TYPE_FIELD_DESC);
+        oprot.writeI32(struct.type.getValue());
+        oprot.writeFieldEnd();
+      }
+      if (struct.functionCall != null) {
+        if (struct.isSetFunctionCall()) {
+          oprot.writeFieldBegin(FUNCTION_CALL_FIELD_DESC);
+          struct.functionCall.write(oprot);
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.literal != null) {
+        if (struct.isSetLiteral()) {
+          oprot.writeFieldBegin(LITERAL_FIELD_DESC);
+          struct.literal.write(oprot);
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.identifier != null) {
+        if (struct.isSetIdentifier()) {
+          oprot.writeFieldBegin(IDENTIFIER_FIELD_DESC);
+          struct.identifier.write(oprot);
+          oprot.writeFieldEnd();
+        }
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+  }
+
+  private static class ExpressionTupleSchemeFactory implements SchemeFactory {
+    public ExpressionTupleScheme getScheme() {
+      return new ExpressionTupleScheme();
+    }
+  }
+
+  private static class ExpressionTupleScheme extends TupleScheme<Expression> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, Expression struct)
+        throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      oprot.writeI32(struct.type.getValue());
+      BitSet optionals = new BitSet();
+      if (struct.isSetFunctionCall()) {
+        optionals.set(0);
+      }
+      if (struct.isSetLiteral()) {
+        optionals.set(1);
+      }
+      if (struct.isSetIdentifier()) {
+        optionals.set(2);
+      }
+      oprot.writeBitSet(optionals, 3);
+      if (struct.isSetFunctionCall()) {
+        struct.functionCall.write(oprot);
+      }
+      if (struct.isSetLiteral()) {
+        struct.literal.write(oprot);
+      }
+      if (struct.isSetIdentifier()) {
+        struct.identifier.write(oprot);
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, Expression struct)
+        throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      struct.type = org.apache.pinot.common.request.ExpressionType.findByValue(iprot.readI32());
+      struct.setTypeIsSet(true);
+      BitSet incoming = iprot.readBitSet(3);
+      if (incoming.get(0)) {
+        struct.functionCall = new Function();
+        struct.functionCall.read(iprot);
+        struct.setFunctionCallIsSet(true);
+      }
+      if (incoming.get(1)) {
+        struct.literal = new Literal();
+        struct.literal.read(iprot);
+        struct.setLiteralIsSet(true);
+      }
+      if (incoming.get(2)) {
+        struct.identifier = new Identifier();
+        struct.identifier.read(iprot);
+        struct.setIdentifierIsSet(true);
+      }
+    }
+  }
+}
+
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/FilterOperator.java b/pinot-common/src/main/java/org/apache/pinot/common/request/ExpressionType.java
similarity index 70%
copy from pinot-common/src/main/java/org/apache/pinot/common/request/FilterOperator.java
copy to pinot-common/src/main/java/org/apache/pinot/common/request/ExpressionType.java
index 2994e5d..dd57180 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/FilterOperator.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/ExpressionType.java
@@ -17,24 +17,19 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
 package org.apache.pinot.common.request;
 
-/**
- * AUTO GENERATED: DO NOT EDIT
- * Filter Operator
- *
- */
-public enum FilterOperator implements org.apache.thrift.TEnum {
-  AND(0), OR(1), EQUALITY(2), NOT(3), RANGE(4), REGEXP_LIKE(5), NOT_IN(6), IN(7);
+public enum ExpressionType implements org.apache.thrift.TEnum {
+  LITERAL(0), IDENTIFIER(1), FUNCTION(2);
 
   private final int value;
 
-  private FilterOperator(int value) {
+  private ExpressionType(int value) {
     this.value = value;
   }
 
@@ -49,24 +44,14 @@ public enum FilterOperator implements org.apache.thrift.TEnum {
    * Find a the enum type by its integer value, as defined in the Thrift IDL.
    * @return null if the value is not found.
    */
-  public static FilterOperator findByValue(int value) {
+  public static ExpressionType findByValue(int value) {
     switch (value) {
       case 0:
-        return AND;
+        return LITERAL;
       case 1:
-        return OR;
+        return IDENTIFIER;
       case 2:
-        return EQUALITY;
-      case 3:
-        return NOT;
-      case 4:
-        return RANGE;
-      case 5:
-        return REGEXP_LIKE;
-      case 6:
-        return NOT_IN;
-      case 7:
-        return IN;
+        return FUNCTION;
       default:
         return null;
     }
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/FilterOperator.java b/pinot-common/src/main/java/org/apache/pinot/common/request/FilterOperator.java
index 2994e5d..d1d6498 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/FilterOperator.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/FilterOperator.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/FilterQuery.java b/pinot-common/src/main/java/org/apache/pinot/common/request/FilterQuery.java
index e070b39..9ad9b5a 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/FilterQuery.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/FilterQuery.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -47,7 +47,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * Filter query
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class FilterQuery implements org.apache.thrift.TBase<FilterQuery, FilterQuery._Fields>, java.io.Serializable, Cloneable, Comparable<FilterQuery> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("FilterQuery");
@@ -436,7 +436,7 @@ public class FilterQuery implements org.apache.thrift.TBase<FilterQuery, FilterQ
   public Object getFieldValue(_Fields field) {
     switch (field) {
       case ID:
-        return Integer.valueOf(getId());
+        return getId();
 
       case COLUMN:
         return getColumn();
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/FilterQueryMap.java b/pinot-common/src/main/java/org/apache/pinot/common/request/FilterQueryMap.java
index 0a78c50..b74f01e 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/FilterQueryMap.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/FilterQueryMap.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -46,7 +46,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * Filter Query is nested but thrift stable version does not support yet (The support is there in top of the trunk but no released jars. Two concerns : stability and onus of maintaining a stable point. Also, its pretty difficult to compile thrift in Linkedin software development environment which is not geared towards c++ dev. Hence, the )
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class FilterQueryMap implements org.apache.thrift.TBase<FilterQueryMap, FilterQueryMap._Fields>, java.io.Serializable, Cloneable, Comparable<FilterQueryMap> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("FilterQueryMap");
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/response/ProcessingException.java b/pinot-common/src/main/java/org/apache/pinot/common/request/Function.java
similarity index 51%
copy from pinot-common/src/main/java/org/apache/pinot/common/response/ProcessingException.java
copy to pinot-common/src/main/java/org/apache/pinot/common/request/Function.java
index a0a8724..3e9e8d2 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/response/ProcessingException.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/Function.java
@@ -17,12 +17,12 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.pinot.common.response;
+package org.apache.pinot.common.request;
 
 import java.util.ArrayList;
 import java.util.BitSet;
@@ -33,8 +33,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.Generated;
-import org.apache.thrift.EncodingUtils;
-import org.apache.thrift.TException;
 import org.apache.thrift.protocol.TTupleProtocol;
 import org.apache.thrift.scheme.IScheme;
 import org.apache.thrift.scheme.SchemeFactory;
@@ -43,34 +41,30 @@ import org.apache.thrift.scheme.TupleScheme;
 
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-/**
- * Processing exception
- *
- */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
-public class ProcessingException extends TException implements org.apache.thrift.TBase<ProcessingException, ProcessingException._Fields>, java.io.Serializable, Cloneable, Comparable<ProcessingException> {
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
+public class Function implements org.apache.thrift.TBase<Function, Function._Fields>, java.io.Serializable, Cloneable, Comparable<Function> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
-      new org.apache.thrift.protocol.TStruct("ProcessingException");
+      new org.apache.thrift.protocol.TStruct("Function");
 
-  private static final org.apache.thrift.protocol.TField ERROR_CODE_FIELD_DESC =
-      new org.apache.thrift.protocol.TField("errorCode", org.apache.thrift.protocol.TType.I32, (short) 1);
-  private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC =
-      new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short) 2);
+  private static final org.apache.thrift.protocol.TField OPERATOR_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("operator", org.apache.thrift.protocol.TType.STRING, (short) 1);
+  private static final org.apache.thrift.protocol.TField OPERANDS_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("operands", org.apache.thrift.protocol.TType.LIST, (short) 2);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes =
       new HashMap<Class<? extends IScheme>, SchemeFactory>();
 
   static {
-    schemes.put(StandardScheme.class, new ProcessingExceptionStandardSchemeFactory());
-    schemes.put(TupleScheme.class, new ProcessingExceptionTupleSchemeFactory());
+    schemes.put(StandardScheme.class, new FunctionStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new FunctionTupleSchemeFactory());
   }
 
-  private int errorCode; // required
-  private String message; // optional
+  private String operator; // required
+  private List<Expression> operands; // optional
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
-    ERROR_CODE((short) 1, "errorCode"), MESSAGE((short) 2, "message");
+    OPERATOR((short) 1, "operator"), OPERANDS((short) 2, "operands");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -85,10 +79,10 @@ public class ProcessingException extends TException implements org.apache.thrift
      */
     public static _Fields findByThriftId(int fieldId) {
       switch (fieldId) {
-        case 1: // ERROR_CODE
-          return ERROR_CODE;
-        case 2: // MESSAGE
-          return MESSAGE;
+        case 1: // OPERATOR
+          return OPERATOR;
+        case 2: // OPERANDS
+          return OPERANDS;
         default:
           return null;
       }
@@ -131,115 +125,134 @@ public class ProcessingException extends TException implements org.apache.thrift
   }
 
   // isset id assignments
-  private static final int __ERRORCODE_ISSET_ID = 0;
-  private byte __isset_bitfield = 0;
-  private static final _Fields optionals[] = {_Fields.MESSAGE};
+  private static final _Fields optionals[] = {_Fields.OPERANDS};
   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
 
   static {
     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap =
         new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.ERROR_CODE,
-        new org.apache.thrift.meta_data.FieldMetaData("errorCode", org.apache.thrift.TFieldRequirementType.REQUIRED,
-            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
-    tmpMap.put(_Fields.MESSAGE,
-        new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.OPERATOR,
+        new org.apache.thrift.meta_data.FieldMetaData("operator", org.apache.thrift.TFieldRequirementType.REQUIRED,
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.OPERANDS,
+        new org.apache.thrift.meta_data.FieldMetaData("operands", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+                new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
+                    Expression.class))));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ProcessingException.class, metaDataMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Function.class, metaDataMap);
   }
 
-  public ProcessingException() {
+  public Function() {
   }
 
-  public ProcessingException(int errorCode) {
+  public Function(String operator) {
     this();
-    this.errorCode = errorCode;
-    setErrorCodeIsSet(true);
+    this.operator = operator;
   }
 
   /**
    * Performs a deep copy on <i>other</i>.
    */
-  public ProcessingException(ProcessingException other) {
-    __isset_bitfield = other.__isset_bitfield;
-    this.errorCode = other.errorCode;
-    if (other.isSetMessage()) {
-      this.message = other.message;
+  public Function(Function other) {
+    if (other.isSetOperator()) {
+      this.operator = other.operator;
+    }
+    if (other.isSetOperands()) {
+      List<Expression> __this__operands = new ArrayList<Expression>(other.operands.size());
+      for (Expression other_element : other.operands) {
+        __this__operands.add(new Expression(other_element));
+      }
+      this.operands = __this__operands;
     }
   }
 
-  public ProcessingException deepCopy() {
-    return new ProcessingException(this);
+  public Function deepCopy() {
+    return new Function(this);
   }
 
   @Override
   public void clear() {
-    setErrorCodeIsSet(false);
-    this.errorCode = 0;
-    this.message = null;
+    this.operator = null;
+    this.operands = null;
+  }
+
+  public String getOperator() {
+    return this.operator;
+  }
+
+  public void setOperator(String operator) {
+    this.operator = operator;
+  }
+
+  public void unsetOperator() {
+    this.operator = null;
   }
 
-  public int getErrorCode() {
-    return this.errorCode;
+  /** Returns true if field operator is set (has been assigned a value) and false otherwise */
+  public boolean isSetOperator() {
+    return this.operator != null;
   }
 
-  public void setErrorCode(int errorCode) {
-    this.errorCode = errorCode;
-    setErrorCodeIsSet(true);
+  public void setOperatorIsSet(boolean value) {
+    if (!value) {
+      this.operator = null;
+    }
   }
 
-  public void unsetErrorCode() {
-    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ERRORCODE_ISSET_ID);
+  public int getOperandsSize() {
+    return (this.operands == null) ? 0 : this.operands.size();
   }
 
-  /** Returns true if field errorCode is set (has been assigned a value) and false otherwise */
-  public boolean isSetErrorCode() {
-    return EncodingUtils.testBit(__isset_bitfield, __ERRORCODE_ISSET_ID);
+  public java.util.Iterator<Expression> getOperandsIterator() {
+    return (this.operands == null) ? null : this.operands.iterator();
   }
 
-  public void setErrorCodeIsSet(boolean value) {
-    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ERRORCODE_ISSET_ID, value);
+  public void addToOperands(Expression elem) {
+    if (this.operands == null) {
+      this.operands = new ArrayList<Expression>();
+    }
+    this.operands.add(elem);
   }
 
-  public String getMessage() {
-    return this.message;
+  public List<Expression> getOperands() {
+    return this.operands;
   }
 
-  public void setMessage(String message) {
-    this.message = message;
+  public void setOperands(List<Expression> operands) {
+    this.operands = operands;
   }
 
-  public void unsetMessage() {
-    this.message = null;
+  public void unsetOperands() {
+    this.operands = null;
   }
 
-  /** Returns true if field message is set (has been assigned a value) and false otherwise */
-  public boolean isSetMessage() {
-    return this.message != null;
+  /** Returns true if field operands is set (has been assigned a value) and false otherwise */
+  public boolean isSetOperands() {
+    return this.operands != null;
   }
 
-  public void setMessageIsSet(boolean value) {
+  public void setOperandsIsSet(boolean value) {
     if (!value) {
-      this.message = null;
+      this.operands = null;
     }
   }
 
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
-      case ERROR_CODE:
+      case OPERATOR:
         if (value == null) {
-          unsetErrorCode();
+          unsetOperator();
         } else {
-          setErrorCode((Integer) value);
+          setOperator((String) value);
         }
         break;
 
-      case MESSAGE:
+      case OPERANDS:
         if (value == null) {
-          unsetMessage();
+          unsetOperands();
         } else {
-          setMessage((String) value);
+          setOperands((List<Expression>) value);
         }
         break;
     }
@@ -247,11 +260,11 @@ public class ProcessingException extends TException implements org.apache.thrift
 
   public Object getFieldValue(_Fields field) {
     switch (field) {
-      case ERROR_CODE:
-        return Integer.valueOf(getErrorCode());
+      case OPERATOR:
+        return getOperator();
 
-      case MESSAGE:
-        return getMessage();
+      case OPERANDS:
+        return getOperands();
     }
     throw new IllegalStateException();
   }
@@ -263,10 +276,10 @@ public class ProcessingException extends TException implements org.apache.thrift
     }
 
     switch (field) {
-      case ERROR_CODE:
-        return isSetErrorCode();
-      case MESSAGE:
-        return isSetMessage();
+      case OPERATOR:
+        return isSetOperator();
+      case OPERANDS:
+        return isSetOperands();
     }
     throw new IllegalStateException();
   }
@@ -276,35 +289,35 @@ public class ProcessingException extends TException implements org.apache.thrift
     if (that == null) {
       return false;
     }
-    if (that instanceof ProcessingException) {
-      return this.equals((ProcessingException) that);
+    if (that instanceof Function) {
+      return this.equals((Function) that);
     }
     return false;
   }
 
-  public boolean equals(ProcessingException that) {
+  public boolean equals(Function that) {
     if (that == null) {
       return false;
     }
 
-    boolean this_present_errorCode = true;
-    boolean that_present_errorCode = true;
-    if (this_present_errorCode || that_present_errorCode) {
-      if (!(this_present_errorCode && that_present_errorCode)) {
+    boolean this_present_operator = true && this.isSetOperator();
+    boolean that_present_operator = true && that.isSetOperator();
+    if (this_present_operator || that_present_operator) {
+      if (!(this_present_operator && that_present_operator)) {
         return false;
       }
-      if (this.errorCode != that.errorCode) {
+      if (!this.operator.equals(that.operator)) {
         return false;
       }
     }
 
-    boolean this_present_message = true && this.isSetMessage();
-    boolean that_present_message = true && that.isSetMessage();
-    if (this_present_message || that_present_message) {
-      if (!(this_present_message && that_present_message)) {
+    boolean this_present_operands = true && this.isSetOperands();
+    boolean that_present_operands = true && that.isSetOperands();
+    if (this_present_operands || that_present_operands) {
+      if (!(this_present_operands && that_present_operands)) {
         return false;
       }
-      if (!this.message.equals(that.message)) {
+      if (!this.operands.equals(that.operands)) {
         return false;
       }
     }
@@ -316,45 +329,45 @@ public class ProcessingException extends TException implements org.apache.thrift
   public int hashCode() {
     List<Object> list = new ArrayList<Object>();
 
-    boolean present_errorCode = true;
-    list.add(present_errorCode);
-    if (present_errorCode) {
-      list.add(errorCode);
+    boolean present_operator = true && (isSetOperator());
+    list.add(present_operator);
+    if (present_operator) {
+      list.add(operator);
     }
 
-    boolean present_message = true && (isSetMessage());
-    list.add(present_message);
-    if (present_message) {
-      list.add(message);
+    boolean present_operands = true && (isSetOperands());
+    list.add(present_operands);
+    if (present_operands) {
+      list.add(operands);
     }
 
     return list.hashCode();
   }
 
   @Override
-  public int compareTo(ProcessingException other) {
+  public int compareTo(Function other) {
     if (!getClass().equals(other.getClass())) {
       return getClass().getName().compareTo(other.getClass().getName());
     }
 
     int lastComparison = 0;
 
-    lastComparison = Boolean.valueOf(isSetErrorCode()).compareTo(other.isSetErrorCode());
+    lastComparison = Boolean.valueOf(isSetOperator()).compareTo(other.isSetOperator());
     if (lastComparison != 0) {
       return lastComparison;
     }
-    if (isSetErrorCode()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.errorCode, other.errorCode);
+    if (isSetOperator()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operator, other.operator);
       if (lastComparison != 0) {
         return lastComparison;
       }
     }
-    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
+    lastComparison = Boolean.valueOf(isSetOperands()).compareTo(other.isSetOperands());
     if (lastComparison != 0) {
       return lastComparison;
     }
-    if (isSetMessage()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
+    if (isSetOperands()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operands, other.operands);
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -378,21 +391,25 @@ public class ProcessingException extends TException implements org.apache.thrift
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder("ProcessingException(");
+    StringBuilder sb = new StringBuilder("Function(");
     boolean first = true;
 
-    sb.append("errorCode:");
-    sb.append(this.errorCode);
+    sb.append("operator:");
+    if (this.operator == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.operator);
+    }
     first = false;
-    if (isSetMessage()) {
+    if (isSetOperands()) {
       if (!first) {
         sb.append(", ");
       }
-      sb.append("message:");
-      if (this.message == null) {
+      sb.append("operands:");
+      if (this.operands == null) {
         sb.append("null");
       } else {
-        sb.append(this.message);
+        sb.append(this.operands);
       }
       first = false;
     }
@@ -403,9 +420,9 @@ public class ProcessingException extends TException implements org.apache.thrift
   public void validate()
       throws org.apache.thrift.TException {
     // check for required fields
-    if (!isSetErrorCode()) {
+    if (!isSetOperator()) {
       throw new org.apache.thrift.protocol.TProtocolException(
-          "Required field 'errorCode' is unset! Struct:" + toString());
+          "Required field 'operator' is unset! Struct:" + toString());
     }
 
     // check for sub-struct validity
@@ -423,23 +440,21 @@ public class ProcessingException extends TException implements org.apache.thrift
   private void readObject(java.io.ObjectInputStream in)
       throws java.io.IOException, ClassNotFoundException {
     try {
-      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
-      __isset_bitfield = 0;
       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
     } catch (org.apache.thrift.TException te) {
       throw new java.io.IOException(te);
     }
   }
 
-  private static class ProcessingExceptionStandardSchemeFactory implements SchemeFactory {
-    public ProcessingExceptionStandardScheme getScheme() {
-      return new ProcessingExceptionStandardScheme();
+  private static class FunctionStandardSchemeFactory implements SchemeFactory {
+    public FunctionStandardScheme getScheme() {
+      return new FunctionStandardScheme();
     }
   }
 
-  private static class ProcessingExceptionStandardScheme extends StandardScheme<ProcessingException> {
+  private static class FunctionStandardScheme extends StandardScheme<Function> {
 
-    public void read(org.apache.thrift.protocol.TProtocol iprot, ProcessingException struct)
+    public void read(org.apache.thrift.protocol.TProtocol iprot, Function struct)
         throws org.apache.thrift.TException {
       org.apache.thrift.protocol.TField schemeField;
       iprot.readStructBegin();
@@ -449,18 +464,28 @@ public class ProcessingException extends TException implements org.apache.thrift
           break;
         }
         switch (schemeField.id) {
-          case 1: // ERROR_CODE
-            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
-              struct.errorCode = iprot.readI32();
-              struct.setErrorCodeIsSet(true);
+          case 1: // OPERATOR
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.operator = iprot.readString();
+              struct.setOperatorIsSet(true);
             } else {
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
-          case 2: // MESSAGE
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.message = iprot.readString();
-              struct.setMessageIsSet(true);
+          case 2: // OPERANDS
+            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
+              {
+                org.apache.thrift.protocol.TList _list52 = iprot.readListBegin();
+                struct.operands = new ArrayList<Expression>(_list52.size);
+                Expression _elem53;
+                for (int _i54 = 0; _i54 < _list52.size; ++_i54) {
+                  _elem53 = new Expression();
+                  _elem53.read(iprot);
+                  struct.operands.add(_elem53);
+                }
+                iprot.readListEnd();
+              }
+              struct.setOperandsIsSet(true);
             } else {
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
@@ -474,18 +499,27 @@ public class ProcessingException extends TException implements org.apache.thrift
       struct.validate();
     }
 
-    public void write(org.apache.thrift.protocol.TProtocol oprot, ProcessingException struct)
+    public void write(org.apache.thrift.protocol.TProtocol oprot, Function struct)
         throws org.apache.thrift.TException {
       struct.validate();
 
       oprot.writeStructBegin(STRUCT_DESC);
-      oprot.writeFieldBegin(ERROR_CODE_FIELD_DESC);
-      oprot.writeI32(struct.errorCode);
-      oprot.writeFieldEnd();
-      if (struct.message != null) {
-        if (struct.isSetMessage()) {
-          oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
-          oprot.writeString(struct.message);
+      if (struct.operator != null) {
+        oprot.writeFieldBegin(OPERATOR_FIELD_DESC);
+        oprot.writeString(struct.operator);
+        oprot.writeFieldEnd();
+      }
+      if (struct.operands != null) {
+        if (struct.isSetOperands()) {
+          oprot.writeFieldBegin(OPERANDS_FIELD_DESC);
+          {
+            oprot.writeListBegin(
+                new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.operands.size()));
+            for (Expression _iter55 : struct.operands) {
+              _iter55.write(oprot);
+            }
+            oprot.writeListEnd();
+          }
           oprot.writeFieldEnd();
         }
       }
@@ -494,39 +528,54 @@ public class ProcessingException extends TException implements org.apache.thrift
     }
   }
 
-  private static class ProcessingExceptionTupleSchemeFactory implements SchemeFactory {
-    public ProcessingExceptionTupleScheme getScheme() {
-      return new ProcessingExceptionTupleScheme();
+  private static class FunctionTupleSchemeFactory implements SchemeFactory {
+    public FunctionTupleScheme getScheme() {
+      return new FunctionTupleScheme();
     }
   }
 
-  private static class ProcessingExceptionTupleScheme extends TupleScheme<ProcessingException> {
+  private static class FunctionTupleScheme extends TupleScheme<Function> {
 
     @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, ProcessingException struct)
+    public void write(org.apache.thrift.protocol.TProtocol prot, Function struct)
         throws org.apache.thrift.TException {
       TTupleProtocol oprot = (TTupleProtocol) prot;
-      oprot.writeI32(struct.errorCode);
+      oprot.writeString(struct.operator);
       BitSet optionals = new BitSet();
-      if (struct.isSetMessage()) {
+      if (struct.isSetOperands()) {
         optionals.set(0);
       }
       oprot.writeBitSet(optionals, 1);
-      if (struct.isSetMessage()) {
-        oprot.writeString(struct.message);
+      if (struct.isSetOperands()) {
+        {
+          oprot.writeI32(struct.operands.size());
+          for (Expression _iter56 : struct.operands) {
+            _iter56.write(oprot);
+          }
+        }
       }
     }
 
     @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, ProcessingException struct)
+    public void read(org.apache.thrift.protocol.TProtocol prot, Function struct)
         throws org.apache.thrift.TException {
       TTupleProtocol iprot = (TTupleProtocol) prot;
-      struct.errorCode = iprot.readI32();
-      struct.setErrorCodeIsSet(true);
+      struct.operator = iprot.readString();
+      struct.setOperatorIsSet(true);
       BitSet incoming = iprot.readBitSet(1);
       if (incoming.get(0)) {
-        struct.message = iprot.readString();
-        struct.setMessageIsSet(true);
+        {
+          org.apache.thrift.protocol.TList _list57 =
+              new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.operands = new ArrayList<Expression>(_list57.size);
+          Expression _elem58;
+          for (int _i59 = 0; _i59 < _list57.size; ++_i59) {
+            _elem58 = new Expression();
+            _elem58.read(iprot);
+            struct.operands.add(_elem58);
+          }
+        }
+        struct.setOperandsIsSet(true);
       }
     }
   }
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/GroupBy.java b/pinot-common/src/main/java/org/apache/pinot/common/request/GroupBy.java
index b79d7e0..bfe9d57 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/GroupBy.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/GroupBy.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -47,7 +47,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * GroupBy
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields>, java.io.Serializable, Cloneable, Comparable<GroupBy> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("GroupBy");
@@ -322,7 +322,7 @@ public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields
         return getColumns();
 
       case TOP_N:
-        return Long.valueOf(getTopN());
+        return getTopN();
 
       case EXPRESSIONS:
         return getExpressions();
@@ -564,12 +564,12 @@ public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields
           case 1: // COLUMNS
             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
               {
-                org.apache.thrift.protocol.TList _list36 = iprot.readListBegin();
-                struct.columns = new ArrayList<String>(_list36.size);
-                String _elem37;
-                for (int _i38 = 0; _i38 < _list36.size; ++_i38) {
-                  _elem37 = iprot.readString();
-                  struct.columns.add(_elem37);
+                org.apache.thrift.protocol.TList _list62 = iprot.readListBegin();
+                struct.columns = new ArrayList<String>(_list62.size);
+                String _elem63;
+                for (int _i64 = 0; _i64 < _list62.size; ++_i64) {
+                  _elem63 = iprot.readString();
+                  struct.columns.add(_elem63);
                 }
                 iprot.readListEnd();
               }
@@ -589,12 +589,12 @@ public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields
           case 3: // EXPRESSIONS
             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
               {
-                org.apache.thrift.protocol.TList _list39 = iprot.readListBegin();
-                struct.expressions = new ArrayList<String>(_list39.size);
-                String _elem40;
-                for (int _i41 = 0; _i41 < _list39.size; ++_i41) {
-                  _elem40 = iprot.readString();
-                  struct.expressions.add(_elem40);
+                org.apache.thrift.protocol.TList _list65 = iprot.readListBegin();
+                struct.expressions = new ArrayList<String>(_list65.size);
+                String _elem66;
+                for (int _i67 = 0; _i67 < _list65.size; ++_i67) {
+                  _elem66 = iprot.readString();
+                  struct.expressions.add(_elem66);
                 }
                 iprot.readListEnd();
               }
@@ -623,8 +623,8 @@ public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields
           {
             oprot.writeListBegin(
                 new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.columns.size()));
-            for (String _iter42 : struct.columns) {
-              oprot.writeString(_iter42);
+            for (String _iter68 : struct.columns) {
+              oprot.writeString(_iter68);
             }
             oprot.writeListEnd();
           }
@@ -642,8 +642,8 @@ public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields
           {
             oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING,
                 struct.expressions.size()));
-            for (String _iter43 : struct.expressions) {
-              oprot.writeString(_iter43);
+            for (String _iter69 : struct.expressions) {
+              oprot.writeString(_iter69);
             }
             oprot.writeListEnd();
           }
@@ -681,8 +681,8 @@ public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields
       if (struct.isSetColumns()) {
         {
           oprot.writeI32(struct.columns.size());
-          for (String _iter44 : struct.columns) {
-            oprot.writeString(_iter44);
+          for (String _iter70 : struct.columns) {
+            oprot.writeString(_iter70);
           }
         }
       }
@@ -692,8 +692,8 @@ public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields
       if (struct.isSetExpressions()) {
         {
           oprot.writeI32(struct.expressions.size());
-          for (String _iter45 : struct.expressions) {
-            oprot.writeString(_iter45);
+          for (String _iter71 : struct.expressions) {
+            oprot.writeString(_iter71);
           }
         }
       }
@@ -706,13 +706,13 @@ public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields
       BitSet incoming = iprot.readBitSet(3);
       if (incoming.get(0)) {
         {
-          org.apache.thrift.protocol.TList _list46 =
+          org.apache.thrift.protocol.TList _list72 =
               new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-          struct.columns = new ArrayList<String>(_list46.size);
-          String _elem47;
-          for (int _i48 = 0; _i48 < _list46.size; ++_i48) {
-            _elem47 = iprot.readString();
-            struct.columns.add(_elem47);
+          struct.columns = new ArrayList<String>(_list72.size);
+          String _elem73;
+          for (int _i74 = 0; _i74 < _list72.size; ++_i74) {
+            _elem73 = iprot.readString();
+            struct.columns.add(_elem73);
           }
         }
         struct.setColumnsIsSet(true);
@@ -723,13 +723,13 @@ public class GroupBy implements org.apache.thrift.TBase<GroupBy, GroupBy._Fields
       }
       if (incoming.get(2)) {
         {
-          org.apache.thrift.protocol.TList _list49 =
+          org.apache.thrift.protocol.TList _list75 =
               new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-          struct.expressions = new ArrayList<String>(_list49.size);
-          String _elem50;
-          for (int _i51 = 0; _i51 < _list49.size; ++_i51) {
-            _elem50 = iprot.readString();
-            struct.expressions.add(_elem50);
+          struct.expressions = new ArrayList<String>(_list75.size);
+          String _elem76;
+          for (int _i77 = 0; _i77 < _list75.size; ++_i77) {
+            _elem76 = iprot.readString();
+            struct.expressions.add(_elem76);
           }
         }
         struct.setExpressionsIsSet(true);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/HavingFilterQuery.java b/pinot-common/src/main/java/org/apache/pinot/common/request/HavingFilterQuery.java
index de28536..ff59b0c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/HavingFilterQuery.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/HavingFilterQuery.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -47,7 +47,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * Having Filter query
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-8-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class HavingFilterQuery implements org.apache.thrift.TBase<HavingFilterQuery, HavingFilterQuery._Fields>, java.io.Serializable, Cloneable, Comparable<HavingFilterQuery> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("HavingFilterQuery");
@@ -437,7 +437,7 @@ public class HavingFilterQuery implements org.apache.thrift.TBase<HavingFilterQu
   public Object getFieldValue(_Fields field) {
     switch (field) {
       case ID:
-        return Integer.valueOf(getId());
+        return getId();
 
       case AGGREGATION_INFO:
         return getAggregationInfo();
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/HavingFilterQueryMap.java b/pinot-common/src/main/java/org/apache/pinot/common/request/HavingFilterQueryMap.java
index 95dbca6..b47b511 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/HavingFilterQueryMap.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/HavingFilterQueryMap.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -41,7 +41,7 @@ import org.apache.thrift.scheme.TupleScheme;
 
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-8-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class HavingFilterQueryMap implements org.apache.thrift.TBase<HavingFilterQueryMap, HavingFilterQueryMap._Fields>, java.io.Serializable, Cloneable, Comparable<HavingFilterQueryMap> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("HavingFilterQueryMap");
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java b/pinot-common/src/main/java/org/apache/pinot/common/request/Identifier.java
similarity index 64%
copy from pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java
copy to pinot-common/src/main/java/org/apache/pinot/common/request/Identifier.java
index ab4b6d4..2bab01d 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/Identifier.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -25,7 +25,6 @@
 package org.apache.pinot.common.request;
 
 import java.util.ArrayList;
-import java.util.BitSet;
 import java.util.Collections;
 import java.util.EnumMap;
 import java.util.EnumSet;
@@ -41,32 +40,27 @@ import org.apache.thrift.scheme.TupleScheme;
 
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-/**
- * AUTO GENERATED: DO NOT EDIT
- * Query source
- *
- */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
-public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySource._Fields>, java.io.Serializable, Cloneable, Comparable<QuerySource> {
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
+public class Identifier implements org.apache.thrift.TBase<Identifier, Identifier._Fields>, java.io.Serializable, Cloneable, Comparable<Identifier> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
-      new org.apache.thrift.protocol.TStruct("QuerySource");
+      new org.apache.thrift.protocol.TStruct("Identifier");
 
-  private static final org.apache.thrift.protocol.TField TABLE_NAME_FIELD_DESC =
-      new org.apache.thrift.protocol.TField("tableName", org.apache.thrift.protocol.TType.STRING, (short) 1);
+  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short) 1);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes =
       new HashMap<Class<? extends IScheme>, SchemeFactory>();
 
   static {
-    schemes.put(StandardScheme.class, new QuerySourceStandardSchemeFactory());
-    schemes.put(TupleScheme.class, new QuerySourceTupleSchemeFactory());
+    schemes.put(StandardScheme.class, new IdentifierStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new IdentifierTupleSchemeFactory());
   }
 
-  private String tableName; // optional
+  private String name; // required
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
-    TABLE_NAME((short) 1, "tableName");
+    NAME((short) 1, "name");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -81,8 +75,8 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
      */
     public static _Fields findByThriftId(int fieldId) {
       switch (fieldId) {
-        case 1: // TABLE_NAME
-          return TABLE_NAME;
+        case 1: // NAME
+          return NAME;
         default:
           return null;
       }
@@ -125,70 +119,74 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
   }
 
   // isset id assignments
-  private static final _Fields optionals[] = {_Fields.TABLE_NAME};
   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
 
   static {
     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap =
         new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.TABLE_NAME,
-        new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.NAME,
+        new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.REQUIRED,
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(QuerySource.class, metaDataMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Identifier.class, metaDataMap);
   }
 
-  public QuerySource() {
+  public Identifier() {
+  }
+
+  public Identifier(String name) {
+    this();
+    this.name = name;
   }
 
   /**
    * Performs a deep copy on <i>other</i>.
    */
-  public QuerySource(QuerySource other) {
-    if (other.isSetTableName()) {
-      this.tableName = other.tableName;
+  public Identifier(Identifier other) {
+    if (other.isSetName()) {
+      this.name = other.name;
     }
   }
 
-  public QuerySource deepCopy() {
-    return new QuerySource(this);
+  public Identifier deepCopy() {
+    return new Identifier(this);
   }
 
   @Override
   public void clear() {
-    this.tableName = null;
+    this.name = null;
   }
 
-  public String getTableName() {
-    return this.tableName;
+  public String getName() {
+    return this.name;
   }
 
-  public void setTableName(String tableName) {
-    this.tableName = tableName;
+  public void setName(String name) {
+    this.name = name;
   }
 
-  public void unsetTableName() {
-    this.tableName = null;
+  public void unsetName() {
+    this.name = null;
   }
 
-  /** Returns true if field tableName is set (has been assigned a value) and false otherwise */
-  public boolean isSetTableName() {
-    return this.tableName != null;
+  /** Returns true if field name is set (has been assigned a value) and false otherwise */
+  public boolean isSetName() {
+    return this.name != null;
   }
 
-  public void setTableNameIsSet(boolean value) {
+  public void setNameIsSet(boolean value) {
     if (!value) {
-      this.tableName = null;
+      this.name = null;
     }
   }
 
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
-      case TABLE_NAME:
+      case NAME:
         if (value == null) {
-          unsetTableName();
+          unsetName();
         } else {
-          setTableName((String) value);
+          setName((String) value);
         }
         break;
     }
@@ -196,8 +194,8 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
 
   public Object getFieldValue(_Fields field) {
     switch (field) {
-      case TABLE_NAME:
-        return getTableName();
+      case NAME:
+        return getName();
     }
     throw new IllegalStateException();
   }
@@ -209,8 +207,8 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
     }
 
     switch (field) {
-      case TABLE_NAME:
-        return isSetTableName();
+      case NAME:
+        return isSetName();
     }
     throw new IllegalStateException();
   }
@@ -220,24 +218,24 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
     if (that == null) {
       return false;
     }
-    if (that instanceof QuerySource) {
-      return this.equals((QuerySource) that);
+    if (that instanceof Identifier) {
+      return this.equals((Identifier) that);
     }
     return false;
   }
 
-  public boolean equals(QuerySource that) {
+  public boolean equals(Identifier that) {
     if (that == null) {
       return false;
     }
 
-    boolean this_present_tableName = true && this.isSetTableName();
-    boolean that_present_tableName = true && that.isSetTableName();
-    if (this_present_tableName || that_present_tableName) {
-      if (!(this_present_tableName && that_present_tableName)) {
+    boolean this_present_name = true && this.isSetName();
+    boolean that_present_name = true && that.isSetName();
+    if (this_present_name || that_present_name) {
+      if (!(this_present_name && that_present_name)) {
         return false;
       }
-      if (!this.tableName.equals(that.tableName)) {
+      if (!this.name.equals(that.name)) {
         return false;
       }
     }
@@ -249,29 +247,29 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
   public int hashCode() {
     List<Object> list = new ArrayList<Object>();
 
-    boolean present_tableName = true && (isSetTableName());
-    list.add(present_tableName);
-    if (present_tableName) {
-      list.add(tableName);
+    boolean present_name = true && (isSetName());
+    list.add(present_name);
+    if (present_name) {
+      list.add(name);
     }
 
     return list.hashCode();
   }
 
   @Override
-  public int compareTo(QuerySource other) {
+  public int compareTo(Identifier other) {
     if (!getClass().equals(other.getClass())) {
       return getClass().getName().compareTo(other.getClass().getName());
     }
 
     int lastComparison = 0;
 
-    lastComparison = Boolean.valueOf(isSetTableName()).compareTo(other.isSetTableName());
+    lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName());
     if (lastComparison != 0) {
       return lastComparison;
     }
-    if (isSetTableName()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableName, other.tableName);
+    if (isSetName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name);
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -295,18 +293,16 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder("QuerySource(");
+    StringBuilder sb = new StringBuilder("Identifier(");
     boolean first = true;
 
-    if (isSetTableName()) {
-      sb.append("tableName:");
-      if (this.tableName == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.tableName);
-      }
-      first = false;
+    sb.append("name:");
+    if (this.name == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.name);
     }
+    first = false;
     sb.append(")");
     return sb.toString();
   }
@@ -314,6 +310,10 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
   public void validate()
       throws org.apache.thrift.TException {
     // check for required fields
+    if (!isSetName()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' is unset! Struct:" + toString());
+    }
+
     // check for sub-struct validity
   }
 
@@ -335,15 +335,15 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
     }
   }
 
-  private static class QuerySourceStandardSchemeFactory implements SchemeFactory {
-    public QuerySourceStandardScheme getScheme() {
-      return new QuerySourceStandardScheme();
+  private static class IdentifierStandardSchemeFactory implements SchemeFactory {
+    public IdentifierStandardScheme getScheme() {
+      return new IdentifierStandardScheme();
     }
   }
 
-  private static class QuerySourceStandardScheme extends StandardScheme<QuerySource> {
+  private static class IdentifierStandardScheme extends StandardScheme<Identifier> {
 
-    public void read(org.apache.thrift.protocol.TProtocol iprot, QuerySource struct)
+    public void read(org.apache.thrift.protocol.TProtocol iprot, Identifier struct)
         throws org.apache.thrift.TException {
       org.apache.thrift.protocol.TField schemeField;
       iprot.readStructBegin();
@@ -353,10 +353,10 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
           break;
         }
         switch (schemeField.id) {
-          case 1: // TABLE_NAME
+          case 1: // NAME
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.tableName = iprot.readString();
-              struct.setTableNameIsSet(true);
+              struct.name = iprot.readString();
+              struct.setNameIsSet(true);
             } else {
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
@@ -370,54 +370,42 @@ public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySo
       struct.validate();
     }
 
-    public void write(org.apache.thrift.protocol.TProtocol oprot, QuerySource struct)
+    public void write(org.apache.thrift.protocol.TProtocol oprot, Identifier struct)
         throws org.apache.thrift.TException {
       struct.validate();
 
       oprot.writeStructBegin(STRUCT_DESC);
-      if (struct.tableName != null) {
-        if (struct.isSetTableName()) {
-          oprot.writeFieldBegin(TABLE_NAME_FIELD_DESC);
-          oprot.writeString(struct.tableName);
-          oprot.writeFieldEnd();
-        }
+      if (struct.name != null) {
+        oprot.writeFieldBegin(NAME_FIELD_DESC);
+        oprot.writeString(struct.name);
+        oprot.writeFieldEnd();
       }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
     }
   }
 
-  private static class QuerySourceTupleSchemeFactory implements SchemeFactory {
-    public QuerySourceTupleScheme getScheme() {
-      return new QuerySourceTupleScheme();
+  private static class IdentifierTupleSchemeFactory implements SchemeFactory {
+    public IdentifierTupleScheme getScheme() {
+      return new IdentifierTupleScheme();
     }
   }
 
-  private static class QuerySourceTupleScheme extends TupleScheme<QuerySource> {
+  private static class IdentifierTupleScheme extends TupleScheme<Identifier> {
 
     @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, QuerySource struct)
+    public void write(org.apache.thrift.protocol.TProtocol prot, Identifier struct)
         throws org.apache.thrift.TException {
       TTupleProtocol oprot = (TTupleProtocol) prot;
-      BitSet optionals = new BitSet();
-      if (struct.isSetTableName()) {
-        optionals.set(0);
-      }
-      oprot.writeBitSet(optionals, 1);
-      if (struct.isSetTableName()) {
-        oprot.writeString(struct.tableName);
-      }
+      oprot.writeString(struct.name);
     }
 
     @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, QuerySource struct)
+    public void read(org.apache.thrift.protocol.TProtocol prot, Identifier struct)
         throws org.apache.thrift.TException {
       TTupleProtocol iprot = (TTupleProtocol) prot;
-      BitSet incoming = iprot.readBitSet(1);
-      if (incoming.get(0)) {
-        struct.tableName = iprot.readString();
-        struct.setTableNameIsSet(true);
-      }
+      struct.name = iprot.readString();
+      struct.setNameIsSet(true);
     }
   }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/InstanceRequest.java b/pinot-common/src/main/java/org/apache/pinot/common/request/InstanceRequest.java
index a182e3b..00b3c4c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/InstanceRequest.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/InstanceRequest.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -47,7 +47,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * Instance Request
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class InstanceRequest implements org.apache.thrift.TBase<InstanceRequest, InstanceRequest._Fields>, java.io.Serializable, Cloneable, Comparable<InstanceRequest> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("InstanceRequest");
@@ -399,7 +399,7 @@ public class InstanceRequest implements org.apache.thrift.TBase<InstanceRequest,
   public Object getFieldValue(_Fields field) {
     switch (field) {
       case REQUEST_ID:
-        return Long.valueOf(getRequestId());
+        return getRequestId();
 
       case QUERY:
         return getQuery();
@@ -408,7 +408,7 @@ public class InstanceRequest implements org.apache.thrift.TBase<InstanceRequest,
         return getSearchSegments();
 
       case ENABLE_TRACE:
-        return Boolean.valueOf(isEnableTrace());
+        return isEnableTrace();
 
       case BROKER_ID:
         return getBrokerId();
@@ -753,12 +753,12 @@ public class InstanceRequest implements org.apache.thrift.TBase<InstanceRequest,
           case 3: // SEARCH_SEGMENTS
             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
               {
-                org.apache.thrift.protocol.TList _list96 = iprot.readListBegin();
-                struct.searchSegments = new ArrayList<String>(_list96.size);
-                String _elem97;
-                for (int _i98 = 0; _i98 < _list96.size; ++_i98) {
-                  _elem97 = iprot.readString();
-                  struct.searchSegments.add(_elem97);
+                org.apache.thrift.protocol.TList _list122 = iprot.readListBegin();
+                struct.searchSegments = new ArrayList<String>(_list122.size);
+                String _elem123;
+                for (int _i124 = 0; _i124 < _list122.size; ++_i124) {
+                  _elem123 = iprot.readString();
+                  struct.searchSegments.add(_elem123);
                 }
                 iprot.readListEnd();
               }
@@ -811,8 +811,8 @@ public class InstanceRequest implements org.apache.thrift.TBase<InstanceRequest,
           {
             oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING,
                 struct.searchSegments.size()));
-            for (String _iter99 : struct.searchSegments) {
-              oprot.writeString(_iter99);
+            for (String _iter125 : struct.searchSegments) {
+              oprot.writeString(_iter125);
             }
             oprot.writeListEnd();
           }
@@ -864,8 +864,8 @@ public class InstanceRequest implements org.apache.thrift.TBase<InstanceRequest,
       if (struct.isSetSearchSegments()) {
         {
           oprot.writeI32(struct.searchSegments.size());
-          for (String _iter100 : struct.searchSegments) {
-            oprot.writeString(_iter100);
+          for (String _iter126 : struct.searchSegments) {
+            oprot.writeString(_iter126);
           }
         }
       }
@@ -889,13 +889,13 @@ public class InstanceRequest implements org.apache.thrift.TBase<InstanceRequest,
       BitSet incoming = iprot.readBitSet(3);
       if (incoming.get(0)) {
         {
-          org.apache.thrift.protocol.TList _list101 =
+          org.apache.thrift.protocol.TList _list127 =
               new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-          struct.searchSegments = new ArrayList<String>(_list101.size);
-          String _elem102;
-          for (int _i103 = 0; _i103 < _list101.size; ++_i103) {
-            _elem102 = iprot.readString();
-            struct.searchSegments.add(_elem102);
+          struct.searchSegments = new ArrayList<String>(_list127.size);
+          String _elem128;
+          for (int _i129 = 0; _i129 < _list127.size; ++_i129) {
+            _elem128 = iprot.readString();
+            struct.searchSegments.add(_elem128);
           }
         }
         struct.setSearchSegmentsIsSet(true);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/Literal.java b/pinot-common/src/main/java/org/apache/pinot/common/request/Literal.java
new file mode 100644
index 0000000..b860beb
--- /dev/null
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/Literal.java
@@ -0,0 +1,771 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Autogenerated by Thrift Compiler (0.9.3)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.pinot.common.request;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.thrift.protocol.TProtocolException;
+
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
+public class Literal extends org.apache.thrift.TUnion<Literal, Literal._Fields> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
+      new org.apache.thrift.protocol.TStruct("Literal");
+  private static final org.apache.thrift.protocol.TField BOOL_VALUE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("boolValue", org.apache.thrift.protocol.TType.BOOL, (short) 1);
+  private static final org.apache.thrift.protocol.TField BYTE_VALUE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("byteValue", org.apache.thrift.protocol.TType.BYTE, (short) 2);
+  private static final org.apache.thrift.protocol.TField SHORT_VALUE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("shortValue", org.apache.thrift.protocol.TType.I16, (short) 3);
+  private static final org.apache.thrift.protocol.TField INT_VALUE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("intValue", org.apache.thrift.protocol.TType.I32, (short) 4);
+  private static final org.apache.thrift.protocol.TField LONG_VALUE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("longValue", org.apache.thrift.protocol.TType.I64, (short) 5);
+  private static final org.apache.thrift.protocol.TField DOUBLE_VALUE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("doubleValue", org.apache.thrift.protocol.TType.DOUBLE, (short) 6);
+  private static final org.apache.thrift.protocol.TField STRING_VALUE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("stringValue", org.apache.thrift.protocol.TType.STRING, (short) 7);
+  private static final org.apache.thrift.protocol.TField BINARY_VALUE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("binaryValue", org.apache.thrift.protocol.TType.STRING, (short) 8);
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    BOOL_VALUE((short) 1, "boolValue"),
+    BYTE_VALUE((short) 2, "byteValue"),
+    SHORT_VALUE((short) 3, "shortValue"),
+    INT_VALUE((short) 4, "intValue"),
+    LONG_VALUE((short) 5, "longValue"),
+    DOUBLE_VALUE((short) 6, "doubleValue"),
+    STRING_VALUE((short) 7, "stringValue"),
+    BINARY_VALUE((short) 8, "binaryValue");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch (fieldId) {
+        case 1: // BOOL_VALUE
+          return BOOL_VALUE;
+        case 2: // BYTE_VALUE
+          return BYTE_VALUE;
+        case 3: // SHORT_VALUE
+          return SHORT_VALUE;
+        case 4: // INT_VALUE
+          return INT_VALUE;
+        case 5: // LONG_VALUE
+          return LONG_VALUE;
+        case 6: // DOUBLE_VALUE
+          return DOUBLE_VALUE;
+        case 7: // STRING_VALUE
+          return STRING_VALUE;
+        case 8: // BINARY_VALUE
+          return BINARY_VALUE;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) {
+        throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      }
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+
+  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+
+  static {
+    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap =
+        new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.BOOL_VALUE,
+        new org.apache.thrift.meta_data.FieldMetaData("boolValue", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
+    tmpMap.put(_Fields.BYTE_VALUE,
+        new org.apache.thrift.meta_data.FieldMetaData("byteValue", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BYTE)));
+    tmpMap.put(_Fields.SHORT_VALUE,
+        new org.apache.thrift.meta_data.FieldMetaData("shortValue", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
+    tmpMap.put(_Fields.INT_VALUE,
+        new org.apache.thrift.meta_data.FieldMetaData("intValue", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+    tmpMap.put(_Fields.LONG_VALUE,
+        new org.apache.thrift.meta_data.FieldMetaData("longValue", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.DOUBLE_VALUE,
+        new org.apache.thrift.meta_data.FieldMetaData("doubleValue", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
+    tmpMap.put(_Fields.STRING_VALUE,
+        new org.apache.thrift.meta_data.FieldMetaData("stringValue", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.BINARY_VALUE,
+        new org.apache.thrift.meta_data.FieldMetaData("binaryValue", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING, true)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Literal.class, metaDataMap);
+  }
+
+  public Literal() {
+    super();
+  }
+
+  public Literal(_Fields setField, Object value) {
+    super(setField, value);
+  }
+
+  public Literal(Literal other) {
+    super(other);
+  }
+
+  public Literal deepCopy() {
+    return new Literal(this);
+  }
+
+  public static Literal boolValue(boolean value) {
+    Literal x = new Literal();
+    x.setBoolValue(value);
+    return x;
+  }
+
+  public static Literal byteValue(byte value) {
+    Literal x = new Literal();
+    x.setByteValue(value);
+    return x;
+  }
+
+  public static Literal shortValue(short value) {
+    Literal x = new Literal();
+    x.setShortValue(value);
+    return x;
+  }
+
+  public static Literal intValue(int value) {
+    Literal x = new Literal();
+    x.setIntValue(value);
+    return x;
+  }
+
+  public static Literal longValue(long value) {
+    Literal x = new Literal();
+    x.setLongValue(value);
+    return x;
+  }
+
+  public static Literal doubleValue(double value) {
+    Literal x = new Literal();
+    x.setDoubleValue(value);
+    return x;
+  }
+
+  public static Literal stringValue(String value) {
+    Literal x = new Literal();
+    x.setStringValue(value);
+    return x;
+  }
+
+  public static Literal binaryValue(ByteBuffer value) {
+    Literal x = new Literal();
+    x.setBinaryValue(value);
+    return x;
+  }
+
+  public static Literal binaryValue(byte[] value) {
+    Literal x = new Literal();
+    x.setBinaryValue(ByteBuffer.wrap(Arrays.copyOf(value, value.length)));
+    return x;
+  }
+
+  @Override
+  protected void checkType(_Fields setField, Object value)
+      throws ClassCastException {
+    switch (setField) {
+      case BOOL_VALUE:
+        if (value instanceof Boolean) {
+          break;
+        }
+        throw new ClassCastException(
+            "Was expecting value of type Boolean for field 'boolValue', but got " + value.getClass().getSimpleName());
+      case BYTE_VALUE:
+        if (value instanceof Byte) {
+          break;
+        }
+        throw new ClassCastException(
+            "Was expecting value of type Byte for field 'byteValue', but got " + value.getClass().getSimpleName());
+      case SHORT_VALUE:
+        if (value instanceof Short) {
+          break;
+        }
+        throw new ClassCastException(
+            "Was expecting value of type Short for field 'shortValue', but got " + value.getClass().getSimpleName());
+      case INT_VALUE:
+        if (value instanceof Integer) {
+          break;
+        }
+        throw new ClassCastException(
+            "Was expecting value of type Integer for field 'intValue', but got " + value.getClass().getSimpleName());
+      case LONG_VALUE:
+        if (value instanceof Long) {
+          break;
+        }
+        throw new ClassCastException(
+            "Was expecting value of type Long for field 'longValue', but got " + value.getClass().getSimpleName());
+      case DOUBLE_VALUE:
+        if (value instanceof Double) {
+          break;
+        }
+        throw new ClassCastException(
+            "Was expecting value of type Double for field 'doubleValue', but got " + value.getClass().getSimpleName());
+      case STRING_VALUE:
+        if (value instanceof String) {
+          break;
+        }
+        throw new ClassCastException(
+            "Was expecting value of type String for field 'stringValue', but got " + value.getClass().getSimpleName());
+      case BINARY_VALUE:
+        if (value instanceof ByteBuffer) {
+          break;
+        }
+        throw new ClassCastException(
+            "Was expecting value of type ByteBuffer for field 'binaryValue', but got " + value.getClass()
+                .getSimpleName());
+      default:
+        throw new IllegalArgumentException("Unknown field id " + setField);
+    }
+  }
+
+  @Override
+  protected Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot,
+      org.apache.thrift.protocol.TField field)
+      throws org.apache.thrift.TException {
+    _Fields setField = _Fields.findByThriftId(field.id);
+    if (setField != null) {
+      switch (setField) {
+        case BOOL_VALUE:
+          if (field.type == BOOL_VALUE_FIELD_DESC.type) {
+            Boolean boolValue;
+            boolValue = iprot.readBool();
+            return boolValue;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        case BYTE_VALUE:
+          if (field.type == BYTE_VALUE_FIELD_DESC.type) {
+            Byte byteValue;
+            byteValue = iprot.readByte();
+            return byteValue;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        case SHORT_VALUE:
+          if (field.type == SHORT_VALUE_FIELD_DESC.type) {
+            Short shortValue;
+            shortValue = iprot.readI16();
+            return shortValue;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        case INT_VALUE:
+          if (field.type == INT_VALUE_FIELD_DESC.type) {
+            Integer intValue;
+            intValue = iprot.readI32();
+            return intValue;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        case LONG_VALUE:
+          if (field.type == LONG_VALUE_FIELD_DESC.type) {
+            Long longValue;
+            longValue = iprot.readI64();
+            return longValue;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        case DOUBLE_VALUE:
+          if (field.type == DOUBLE_VALUE_FIELD_DESC.type) {
+            Double doubleValue;
+            doubleValue = iprot.readDouble();
+            return doubleValue;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        case STRING_VALUE:
+          if (field.type == STRING_VALUE_FIELD_DESC.type) {
+            String stringValue;
+            stringValue = iprot.readString();
+            return stringValue;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        case BINARY_VALUE:
+          if (field.type == BINARY_VALUE_FIELD_DESC.type) {
+            ByteBuffer binaryValue;
+            binaryValue = iprot.readBinary();
+            return binaryValue;
+          } else {
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+            return null;
+          }
+        default:
+          throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
+      }
+    } else {
+      org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
+      return null;
+    }
+  }
+
+  @Override
+  protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot)
+      throws org.apache.thrift.TException {
+    switch (setField_) {
+      case BOOL_VALUE:
+        Boolean boolValue = (Boolean) value_;
+        oprot.writeBool(boolValue);
+        return;
+      case BYTE_VALUE:
+        Byte byteValue = (Byte) value_;
+        oprot.writeByte(byteValue);
+        return;
+      case SHORT_VALUE:
+        Short shortValue = (Short) value_;
+        oprot.writeI16(shortValue);
+        return;
+      case INT_VALUE:
+        Integer intValue = (Integer) value_;
+        oprot.writeI32(intValue);
+        return;
+      case LONG_VALUE:
+        Long longValue = (Long) value_;
+        oprot.writeI64(longValue);
+        return;
+      case DOUBLE_VALUE:
+        Double doubleValue = (Double) value_;
+        oprot.writeDouble(doubleValue);
+        return;
+      case STRING_VALUE:
+        String stringValue = (String) value_;
+        oprot.writeString(stringValue);
+        return;
+      case BINARY_VALUE:
+        ByteBuffer binaryValue = (ByteBuffer) value_;
+        oprot.writeBinary(binaryValue);
+        return;
+      default:
+        throw new IllegalStateException("Cannot write union with unknown field " + setField_);
+    }
+  }
+
+  @Override
+  protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID)
+      throws org.apache.thrift.TException {
+    _Fields setField = _Fields.findByThriftId(fieldID);
+    if (setField != null) {
+      switch (setField) {
+        case BOOL_VALUE:
+          Boolean boolValue;
+          boolValue = iprot.readBool();
+          return boolValue;
+        case BYTE_VALUE:
+          Byte byteValue;
+          byteValue = iprot.readByte();
+          return byteValue;
+        case SHORT_VALUE:
+          Short shortValue;
+          shortValue = iprot.readI16();
+          return shortValue;
+        case INT_VALUE:
+          Integer intValue;
+          intValue = iprot.readI32();
+          return intValue;
+        case LONG_VALUE:
+          Long longValue;
+          longValue = iprot.readI64();
+          return longValue;
+        case DOUBLE_VALUE:
+          Double doubleValue;
+          doubleValue = iprot.readDouble();
+          return doubleValue;
+        case STRING_VALUE:
+          String stringValue;
+          stringValue = iprot.readString();
+          return stringValue;
+        case BINARY_VALUE:
+          ByteBuffer binaryValue;
+          binaryValue = iprot.readBinary();
+          return binaryValue;
+        default:
+          throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
+      }
+    } else {
+      throw new TProtocolException("Couldn't find a field with field id " + fieldID);
+    }
+  }
+
+  @Override
+  protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot)
+      throws org.apache.thrift.TException {
+    switch (setField_) {
+      case BOOL_VALUE:
+        Boolean boolValue = (Boolean) value_;
+        oprot.writeBool(boolValue);
+        return;
+      case BYTE_VALUE:
+        Byte byteValue = (Byte) value_;
+        oprot.writeByte(byteValue);
+        return;
+      case SHORT_VALUE:
+        Short shortValue = (Short) value_;
+        oprot.writeI16(shortValue);
+        return;
+      case INT_VALUE:
+        Integer intValue = (Integer) value_;
+        oprot.writeI32(intValue);
+        return;
+      case LONG_VALUE:
+        Long longValue = (Long) value_;
+        oprot.writeI64(longValue);
+        return;
+      case DOUBLE_VALUE:
+        Double doubleValue = (Double) value_;
+        oprot.writeDouble(doubleValue);
+        return;
+      case STRING_VALUE:
+        String stringValue = (String) value_;
+        oprot.writeString(stringValue);
+        return;
+      case BINARY_VALUE:
+        ByteBuffer binaryValue = (ByteBuffer) value_;
+        oprot.writeBinary(binaryValue);
+        return;
+      default:
+        throw new IllegalStateException("Cannot write union with unknown field " + setField_);
+    }
+  }
+
+  @Override
+  protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {
+    switch (setField) {
+      case BOOL_VALUE:
+        return BOOL_VALUE_FIELD_DESC;
+      case BYTE_VALUE:
+        return BYTE_VALUE_FIELD_DESC;
+      case SHORT_VALUE:
+        return SHORT_VALUE_FIELD_DESC;
+      case INT_VALUE:
+        return INT_VALUE_FIELD_DESC;
+      case LONG_VALUE:
+        return LONG_VALUE_FIELD_DESC;
+      case DOUBLE_VALUE:
+        return DOUBLE_VALUE_FIELD_DESC;
+      case STRING_VALUE:
+        return STRING_VALUE_FIELD_DESC;
+      case BINARY_VALUE:
+        return BINARY_VALUE_FIELD_DESC;
+      default:
+        throw new IllegalArgumentException("Unknown field id " + setField);
+    }
+  }
+
+  @Override
+  protected org.apache.thrift.protocol.TStruct getStructDesc() {
+    return STRUCT_DESC;
+  }
+
+  @Override
+  protected _Fields enumForId(short id) {
+    return _Fields.findByThriftIdOrThrow(id);
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public boolean getBoolValue() {
+    if (getSetField() == _Fields.BOOL_VALUE) {
+      return (Boolean) getFieldValue();
+    } else {
+      throw new RuntimeException(
+          "Cannot get field 'boolValue' because union is currently set to " + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setBoolValue(boolean value) {
+    setField_ = _Fields.BOOL_VALUE;
+    value_ = value;
+  }
+
+  public byte getByteValue() {
+    if (getSetField() == _Fields.BYTE_VALUE) {
+      return (Byte) getFieldValue();
+    } else {
+      throw new RuntimeException(
+          "Cannot get field 'byteValue' because union is currently set to " + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setByteValue(byte value) {
+    setField_ = _Fields.BYTE_VALUE;
+    value_ = value;
+  }
+
+  public short getShortValue() {
+    if (getSetField() == _Fields.SHORT_VALUE) {
+      return (Short) getFieldValue();
+    } else {
+      throw new RuntimeException(
+          "Cannot get field 'shortValue' because union is currently set to " + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setShortValue(short value) {
+    setField_ = _Fields.SHORT_VALUE;
+    value_ = value;
+  }
+
+  public int getIntValue() {
+    if (getSetField() == _Fields.INT_VALUE) {
+      return (Integer) getFieldValue();
+    } else {
+      throw new RuntimeException(
+          "Cannot get field 'intValue' because union is currently set to " + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setIntValue(int value) {
+    setField_ = _Fields.INT_VALUE;
+    value_ = value;
+  }
+
+  public long getLongValue() {
+    if (getSetField() == _Fields.LONG_VALUE) {
+      return (Long) getFieldValue();
+    } else {
+      throw new RuntimeException(
+          "Cannot get field 'longValue' because union is currently set to " + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setLongValue(long value) {
+    setField_ = _Fields.LONG_VALUE;
+    value_ = value;
+  }
+
+  public double getDoubleValue() {
+    if (getSetField() == _Fields.DOUBLE_VALUE) {
+      return (Double) getFieldValue();
+    } else {
+      throw new RuntimeException(
+          "Cannot get field 'doubleValue' because union is currently set to " + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setDoubleValue(double value) {
+    setField_ = _Fields.DOUBLE_VALUE;
+    value_ = value;
+  }
+
+  public String getStringValue() {
+    if (getSetField() == _Fields.STRING_VALUE) {
+      return (String) getFieldValue();
+    } else {
+      throw new RuntimeException(
+          "Cannot get field 'stringValue' because union is currently set to " + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setStringValue(String value) {
+    if (value == null) {
+      throw new NullPointerException();
+    }
+    setField_ = _Fields.STRING_VALUE;
+    value_ = value;
+  }
+
+  public byte[] getBinaryValue() {
+    setBinaryValue(org.apache.thrift.TBaseHelper.rightSize(bufferForBinaryValue()));
+    ByteBuffer b = bufferForBinaryValue();
+    return b == null ? null : b.array();
+  }
+
+  public ByteBuffer bufferForBinaryValue() {
+    if (getSetField() == _Fields.BINARY_VALUE) {
+      return org.apache.thrift.TBaseHelper.copyBinary((ByteBuffer) getFieldValue());
+    } else {
+      throw new RuntimeException(
+          "Cannot get field 'binaryValue' because union is currently set to " + getFieldDesc(getSetField()).name);
+    }
+  }
+
+  public void setBinaryValue(byte[] value) {
+    setBinaryValue(ByteBuffer.wrap(Arrays.copyOf(value, value.length)));
+  }
+
+  public void setBinaryValue(ByteBuffer value) {
+    if (value == null) {
+      throw new NullPointerException();
+    }
+    setField_ = _Fields.BINARY_VALUE;
+    value_ = value;
+  }
+
+  public boolean isSetBoolValue() {
+    return setField_ == _Fields.BOOL_VALUE;
+  }
+
+  public boolean isSetByteValue() {
+    return setField_ == _Fields.BYTE_VALUE;
+  }
+
+  public boolean isSetShortValue() {
+    return setField_ == _Fields.SHORT_VALUE;
+  }
+
+  public boolean isSetIntValue() {
+    return setField_ == _Fields.INT_VALUE;
+  }
+
+  public boolean isSetLongValue() {
+    return setField_ == _Fields.LONG_VALUE;
+  }
+
+  public boolean isSetDoubleValue() {
+    return setField_ == _Fields.DOUBLE_VALUE;
+  }
+
+  public boolean isSetStringValue() {
+    return setField_ == _Fields.STRING_VALUE;
+  }
+
+  public boolean isSetBinaryValue() {
+    return setField_ == _Fields.BINARY_VALUE;
+  }
+
+  public boolean equals(Object other) {
+    if (other instanceof Literal) {
+      return equals((Literal) other);
+    } else {
+      return false;
+    }
+  }
+
+  public boolean equals(Literal other) {
+    return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());
+  }
+
+  @Override
+  public int compareTo(Literal other) {
+    int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), other.getSetField());
+    if (lastComparison == 0) {
+      return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
+    }
+    return lastComparison;
+  }
+
+  @Override
+  public int hashCode() {
+    List<Object> list = new ArrayList<Object>();
+    list.add(this.getClass().getName());
+    org.apache.thrift.TFieldIdEnum setField = getSetField();
+    if (setField != null) {
+      list.add(setField.getThriftFieldId());
+      Object value = getFieldValue();
+      if (value instanceof org.apache.thrift.TEnum) {
+        list.add(((org.apache.thrift.TEnum) getFieldValue()).getValue());
+      } else {
+        list.add(value);
+      }
+    }
+    return list.hashCode();
+  }
+
+  private void writeObject(java.io.ObjectOutputStream out)
+      throws java.io.IOException {
+    try {
+      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private void readObject(java.io.ObjectInputStream in)
+      throws java.io.IOException, ClassNotFoundException {
+    try {
+      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/PinotQuery.java b/pinot-common/src/main/java/org/apache/pinot/common/request/PinotQuery.java
new file mode 100644
index 0000000..8e8676b
--- /dev/null
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/PinotQuery.java
@@ -0,0 +1,1807 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Autogenerated by Thrift Compiler (0.9.3)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.pinot.common.request;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Generated;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+import org.apache.thrift.scheme.TupleScheme;
+
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
+public class PinotQuery implements org.apache.thrift.TBase<PinotQuery, PinotQuery._Fields>, java.io.Serializable, Cloneable, Comparable<PinotQuery> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
+      new org.apache.thrift.protocol.TStruct("PinotQuery");
+
+  private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.I32, (short) 1);
+  private static final org.apache.thrift.protocol.TField DATA_SOURCE_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("dataSource", org.apache.thrift.protocol.TType.STRUCT, (short) 2);
+  private static final org.apache.thrift.protocol.TField SELECT_LIST_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("selectList", org.apache.thrift.protocol.TType.LIST, (short) 3);
+  private static final org.apache.thrift.protocol.TField FILTER_EXPRESSION_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("filterExpression", org.apache.thrift.protocol.TType.STRUCT, (short) 4);
+  private static final org.apache.thrift.protocol.TField GROUP_BY_LIST_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("groupByList", org.apache.thrift.protocol.TType.LIST, (short) 5);
+  private static final org.apache.thrift.protocol.TField ORDER_BY_LIST_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("orderByList", org.apache.thrift.protocol.TType.LIST, (short) 6);
+  private static final org.apache.thrift.protocol.TField HAVING_EXPRESSION_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("havingExpression", org.apache.thrift.protocol.TType.STRUCT, (short) 7);
+  private static final org.apache.thrift.protocol.TField LIMIT_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("limit", org.apache.thrift.protocol.TType.I32, (short) 8);
+  private static final org.apache.thrift.protocol.TField OFFSET_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("offset", org.apache.thrift.protocol.TType.I32, (short) 9);
+  private static final org.apache.thrift.protocol.TField DEBUG_OPTIONS_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("debugOptions", org.apache.thrift.protocol.TType.MAP, (short) 10);
+  private static final org.apache.thrift.protocol.TField QUERY_OPTIONS_FIELD_DESC =
+      new org.apache.thrift.protocol.TField("queryOptions", org.apache.thrift.protocol.TType.MAP, (short) 11);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes =
+      new HashMap<Class<? extends IScheme>, SchemeFactory>();
+
+  static {
+    schemes.put(StandardScheme.class, new PinotQueryStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new PinotQueryTupleSchemeFactory());
+  }
+
+  private int version; // optional
+  private DataSource dataSource; // optional
+  private List<Expression> selectList; // optional
+  private Expression filterExpression; // optional
+  private List<Expression> groupByList; // optional
+  private List<Expression> orderByList; // optional
+  private Expression havingExpression; // optional
+  private int limit; // optional
+  private int offset; // optional
+  private Map<String, String> debugOptions; // optional
+  private Map<String, String> queryOptions; // optional
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    VERSION((short) 1, "version"),
+    DATA_SOURCE((short) 2, "dataSource"),
+    SELECT_LIST((short) 3, "selectList"),
+    FILTER_EXPRESSION((short) 4, "filterExpression"),
+    GROUP_BY_LIST((short) 5, "groupByList"),
+    ORDER_BY_LIST((short) 6, "orderByList"),
+    HAVING_EXPRESSION((short) 7, "havingExpression"),
+    LIMIT((short) 8, "limit"),
+    OFFSET((short) 9, "offset"),
+    DEBUG_OPTIONS((short) 10, "debugOptions"),
+    QUERY_OPTIONS((short) 11, "queryOptions");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch (fieldId) {
+        case 1: // VERSION
+          return VERSION;
+        case 2: // DATA_SOURCE
+          return DATA_SOURCE;
+        case 3: // SELECT_LIST
+          return SELECT_LIST;
+        case 4: // FILTER_EXPRESSION
+          return FILTER_EXPRESSION;
+        case 5: // GROUP_BY_LIST
+          return GROUP_BY_LIST;
+        case 6: // ORDER_BY_LIST
+          return ORDER_BY_LIST;
+        case 7: // HAVING_EXPRESSION
+          return HAVING_EXPRESSION;
+        case 8: // LIMIT
+          return LIMIT;
+        case 9: // OFFSET
+          return OFFSET;
+        case 10: // DEBUG_OPTIONS
+          return DEBUG_OPTIONS;
+        case 11: // QUERY_OPTIONS
+          return QUERY_OPTIONS;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) {
+        throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      }
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+
+  // isset id assignments
+  private static final int __VERSION_ISSET_ID = 0;
+  private static final int __LIMIT_ISSET_ID = 1;
+  private static final int __OFFSET_ISSET_ID = 2;
+  private byte __isset_bitfield = 0;
+  private static final _Fields optionals[] =
+      {_Fields.VERSION, _Fields.DATA_SOURCE, _Fields.SELECT_LIST, _Fields.FILTER_EXPRESSION, _Fields.GROUP_BY_LIST, _Fields.ORDER_BY_LIST, _Fields.HAVING_EXPRESSION, _Fields.LIMIT, _Fields.OFFSET, _Fields.DEBUG_OPTIONS, _Fields.QUERY_OPTIONS};
+  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+
+  static {
+    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap =
+        new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.VERSION,
+        new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+    tmpMap.put(_Fields.DATA_SOURCE,
+        new org.apache.thrift.meta_data.FieldMetaData("dataSource", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, DataSource.class)));
+    tmpMap.put(_Fields.SELECT_LIST,
+        new org.apache.thrift.meta_data.FieldMetaData("selectList", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT,
+                    "Expression"))));
+    tmpMap.put(_Fields.FILTER_EXPRESSION, new org.apache.thrift.meta_data.FieldMetaData("filterExpression",
+        org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT, "Expression")));
+    tmpMap.put(_Fields.GROUP_BY_LIST,
+        new org.apache.thrift.meta_data.FieldMetaData("groupByList", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT,
+                    "Expression"))));
+    tmpMap.put(_Fields.ORDER_BY_LIST,
+        new org.apache.thrift.meta_data.FieldMetaData("orderByList", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT,
+                    "Expression"))));
+    tmpMap.put(_Fields.HAVING_EXPRESSION, new org.apache.thrift.meta_data.FieldMetaData("havingExpression",
+        org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT, "Expression")));
+    tmpMap.put(_Fields.LIMIT,
+        new org.apache.thrift.meta_data.FieldMetaData("limit", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+    tmpMap.put(_Fields.OFFSET,
+        new org.apache.thrift.meta_data.FieldMetaData("offset", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+    tmpMap.put(_Fields.DEBUG_OPTIONS,
+        new org.apache.thrift.meta_data.FieldMetaData("debugOptions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
+                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
+                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
+    tmpMap.put(_Fields.QUERY_OPTIONS,
+        new org.apache.thrift.meta_data.FieldMetaData("queryOptions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+            new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
+                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
+                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PinotQuery.class, metaDataMap);
+  }
+
+  public PinotQuery() {
+    this.limit = 10;
+
+    this.offset = 0;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public PinotQuery(PinotQuery other) {
+    __isset_bitfield = other.__isset_bitfield;
+    this.version = other.version;
+    if (other.isSetDataSource()) {
+      this.dataSource = new DataSource(other.dataSource);
+    }
+    if (other.isSetSelectList()) {
+      List<Expression> __this__selectList = new ArrayList<Expression>(other.selectList.size());
+      for (Expression other_element : other.selectList) {
+        __this__selectList.add(other_element);
+      }
+      this.selectList = __this__selectList;
+    }
+    if (other.isSetFilterExpression()) {
+      this.filterExpression = other.filterExpression;
+    }
+    if (other.isSetGroupByList()) {
+      List<Expression> __this__groupByList = new ArrayList<Expression>(other.groupByList.size());
+      for (Expression other_element : other.groupByList) {
+        __this__groupByList.add(other_element);
+      }
+      this.groupByList = __this__groupByList;
+    }
+    if (other.isSetOrderByList()) {
+      List<Expression> __this__orderByList = new ArrayList<Expression>(other.orderByList.size());
+      for (Expression other_element : other.orderByList) {
+        __this__orderByList.add(other_element);
+      }
+      this.orderByList = __this__orderByList;
+    }
+    if (other.isSetHavingExpression()) {
+      this.havingExpression = other.havingExpression;
+    }
+    this.limit = other.limit;
+    this.offset = other.offset;
+    if (other.isSetDebugOptions()) {
+      Map<String, String> __this__debugOptions = new HashMap<String, String>(other.debugOptions);
+      this.debugOptions = __this__debugOptions;
+    }
+    if (other.isSetQueryOptions()) {
+      Map<String, String> __this__queryOptions = new HashMap<String, String>(other.queryOptions);
+      this.queryOptions = __this__queryOptions;
+    }
+  }
+
+  public PinotQuery deepCopy() {
+    return new PinotQuery(this);
+  }
+
+  @Override
+  public void clear() {
+    setVersionIsSet(false);
+    this.version = 0;
+    this.dataSource = null;
+    this.selectList = null;
+    this.filterExpression = null;
+    this.groupByList = null;
+    this.orderByList = null;
+    this.havingExpression = null;
+    this.limit = 10;
+
+    this.offset = 0;
+
+    this.debugOptions = null;
+    this.queryOptions = null;
+  }
+
+  public int getVersion() {
+    return this.version;
+  }
+
+  public void setVersion(int version) {
+    this.version = version;
+    setVersionIsSet(true);
+  }
+
+  public void unsetVersion() {
+    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __VERSION_ISSET_ID);
+  }
+
+  /** Returns true if field version is set (has been assigned a value) and false otherwise */
+  public boolean isSetVersion() {
+    return EncodingUtils.testBit(__isset_bitfield, __VERSION_ISSET_ID);
+  }
+
+  public void setVersionIsSet(boolean value) {
+    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __VERSION_ISSET_ID, value);
+  }
+
+  public DataSource getDataSource() {
+    return this.dataSource;
+  }
+
+  public void setDataSource(DataSource dataSource) {
+    this.dataSource = dataSource;
+  }
+
+  public void unsetDataSource() {
+    this.dataSource = null;
+  }
+
+  /** Returns true if field dataSource is set (has been assigned a value) and false otherwise */
+  public boolean isSetDataSource() {
+    return this.dataSource != null;
+  }
+
+  public void setDataSourceIsSet(boolean value) {
+    if (!value) {
+      this.dataSource = null;
+    }
+  }
+
+  public int getSelectListSize() {
+    return (this.selectList == null) ? 0 : this.selectList.size();
+  }
+
+  public java.util.Iterator<Expression> getSelectListIterator() {
+    return (this.selectList == null) ? null : this.selectList.iterator();
+  }
+
+  public void addToSelectList(Expression elem) {
+    if (this.selectList == null) {
+      this.selectList = new ArrayList<Expression>();
+    }
+    this.selectList.add(elem);
+  }
+
+  public List<Expression> getSelectList() {
+    return this.selectList;
+  }
+
+  public void setSelectList(List<Expression> selectList) {
+    this.selectList = selectList;
+  }
+
+  public void unsetSelectList() {
+    this.selectList = null;
+  }
+
+  /** Returns true if field selectList is set (has been assigned a value) and false otherwise */
+  public boolean isSetSelectList() {
+    return this.selectList != null;
+  }
+
+  public void setSelectListIsSet(boolean value) {
+    if (!value) {
+      this.selectList = null;
+    }
+  }
+
+  public Expression getFilterExpression() {
+    return this.filterExpression;
+  }
+
+  public void setFilterExpression(Expression filterExpression) {
+    this.filterExpression = filterExpression;
+  }
+
+  public void unsetFilterExpression() {
+    this.filterExpression = null;
+  }
+
+  /** Returns true if field filterExpression is set (has been assigned a value) and false otherwise */
+  public boolean isSetFilterExpression() {
+    return this.filterExpression != null;
+  }
+
+  public void setFilterExpressionIsSet(boolean value) {
+    if (!value) {
+      this.filterExpression = null;
+    }
+  }
+
+  public int getGroupByListSize() {
+    return (this.groupByList == null) ? 0 : this.groupByList.size();
+  }
+
+  public java.util.Iterator<Expression> getGroupByListIterator() {
+    return (this.groupByList == null) ? null : this.groupByList.iterator();
+  }
+
+  public void addToGroupByList(Expression elem) {
+    if (this.groupByList == null) {
+      this.groupByList = new ArrayList<Expression>();
+    }
+    this.groupByList.add(elem);
+  }
+
+  public List<Expression> getGroupByList() {
+    return this.groupByList;
+  }
+
+  public void setGroupByList(List<Expression> groupByList) {
+    this.groupByList = groupByList;
+  }
+
+  public void unsetGroupByList() {
+    this.groupByList = null;
+  }
+
+  /** Returns true if field groupByList is set (has been assigned a value) and false otherwise */
+  public boolean isSetGroupByList() {
+    return this.groupByList != null;
+  }
+
+  public void setGroupByListIsSet(boolean value) {
+    if (!value) {
+      this.groupByList = null;
+    }
+  }
+
+  public int getOrderByListSize() {
+    return (this.orderByList == null) ? 0 : this.orderByList.size();
+  }
+
+  public java.util.Iterator<Expression> getOrderByListIterator() {
+    return (this.orderByList == null) ? null : this.orderByList.iterator();
+  }
+
+  public void addToOrderByList(Expression elem) {
+    if (this.orderByList == null) {
+      this.orderByList = new ArrayList<Expression>();
+    }
+    this.orderByList.add(elem);
+  }
+
+  public List<Expression> getOrderByList() {
+    return this.orderByList;
+  }
+
+  public void setOrderByList(List<Expression> orderByList) {
+    this.orderByList = orderByList;
+  }
+
+  public void unsetOrderByList() {
+    this.orderByList = null;
+  }
+
+  /** Returns true if field orderByList is set (has been assigned a value) and false otherwise */
+  public boolean isSetOrderByList() {
+    return this.orderByList != null;
+  }
+
+  public void setOrderByListIsSet(boolean value) {
+    if (!value) {
+      this.orderByList = null;
+    }
+  }
+
+  public Expression getHavingExpression() {
+    return this.havingExpression;
+  }
+
+  public void setHavingExpression(Expression havingExpression) {
+    this.havingExpression = havingExpression;
+  }
+
+  public void unsetHavingExpression() {
+    this.havingExpression = null;
+  }
+
+  /** Returns true if field havingExpression is set (has been assigned a value) and false otherwise */
+  public boolean isSetHavingExpression() {
+    return this.havingExpression != null;
+  }
+
+  public void setHavingExpressionIsSet(boolean value) {
+    if (!value) {
+      this.havingExpression = null;
+    }
+  }
+
+  public int getLimit() {
+    return this.limit;
+  }
+
+  public void setLimit(int limit) {
+    this.limit = limit;
+    setLimitIsSet(true);
+  }
+
+  public void unsetLimit() {
+    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __LIMIT_ISSET_ID);
+  }
+
+  /** Returns true if field limit is set (has been assigned a value) and false otherwise */
+  public boolean isSetLimit() {
+    return EncodingUtils.testBit(__isset_bitfield, __LIMIT_ISSET_ID);
+  }
+
+  public void setLimitIsSet(boolean value) {
+    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __LIMIT_ISSET_ID, value);
+  }
+
+  public int getOffset() {
+    return this.offset;
+  }
+
+  public void setOffset(int offset) {
+    this.offset = offset;
+    setOffsetIsSet(true);
+  }
+
+  public void unsetOffset() {
+    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __OFFSET_ISSET_ID);
+  }
+
+  /** Returns true if field offset is set (has been assigned a value) and false otherwise */
+  public boolean isSetOffset() {
+    return EncodingUtils.testBit(__isset_bitfield, __OFFSET_ISSET_ID);
+  }
+
+  public void setOffsetIsSet(boolean value) {
+    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __OFFSET_ISSET_ID, value);
+  }
+
+  public int getDebugOptionsSize() {
+    return (this.debugOptions == null) ? 0 : this.debugOptions.size();
+  }
+
+  public void putToDebugOptions(String key, String val) {
+    if (this.debugOptions == null) {
+      this.debugOptions = new HashMap<String, String>();
+    }
+    this.debugOptions.put(key, val);
+  }
+
+  public Map<String, String> getDebugOptions() {
+    return this.debugOptions;
+  }
+
+  public void setDebugOptions(Map<String, String> debugOptions) {
+    this.debugOptions = debugOptions;
+  }
+
+  public void unsetDebugOptions() {
+    this.debugOptions = null;
+  }
+
+  /** Returns true if field debugOptions is set (has been assigned a value) and false otherwise */
+  public boolean isSetDebugOptions() {
+    return this.debugOptions != null;
+  }
+
+  public void setDebugOptionsIsSet(boolean value) {
+    if (!value) {
+      this.debugOptions = null;
+    }
+  }
+
+  public int getQueryOptionsSize() {
+    return (this.queryOptions == null) ? 0 : this.queryOptions.size();
+  }
+
+  public void putToQueryOptions(String key, String val) {
+    if (this.queryOptions == null) {
+      this.queryOptions = new HashMap<String, String>();
+    }
+    this.queryOptions.put(key, val);
+  }
+
+  public Map<String, String> getQueryOptions() {
+    return this.queryOptions;
+  }
+
+  public void setQueryOptions(Map<String, String> queryOptions) {
+    this.queryOptions = queryOptions;
+  }
+
+  public void unsetQueryOptions() {
+    this.queryOptions = null;
+  }
+
+  /** Returns true if field queryOptions is set (has been assigned a value) and false otherwise */
+  public boolean isSetQueryOptions() {
+    return this.queryOptions != null;
+  }
+
+  public void setQueryOptionsIsSet(boolean value) {
+    if (!value) {
+      this.queryOptions = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+      case VERSION:
+        if (value == null) {
+          unsetVersion();
+        } else {
+          setVersion((Integer) value);
+        }
+        break;
+
+      case DATA_SOURCE:
+        if (value == null) {
+          unsetDataSource();
+        } else {
+          setDataSource((DataSource) value);
+        }
+        break;
+
+      case SELECT_LIST:
+        if (value == null) {
+          unsetSelectList();
+        } else {
+          setSelectList((List<Expression>) value);
+        }
+        break;
+
+      case FILTER_EXPRESSION:
+        if (value == null) {
+          unsetFilterExpression();
+        } else {
+          setFilterExpression((Expression) value);
+        }
+        break;
+
+      case GROUP_BY_LIST:
+        if (value == null) {
+          unsetGroupByList();
+        } else {
+          setGroupByList((List<Expression>) value);
+        }
+        break;
+
+      case ORDER_BY_LIST:
+        if (value == null) {
+          unsetOrderByList();
+        } else {
+          setOrderByList((List<Expression>) value);
+        }
+        break;
+
+      case HAVING_EXPRESSION:
+        if (value == null) {
+          unsetHavingExpression();
+        } else {
+          setHavingExpression((Expression) value);
+        }
+        break;
+
+      case LIMIT:
+        if (value == null) {
+          unsetLimit();
+        } else {
+          setLimit((Integer) value);
+        }
+        break;
+
+      case OFFSET:
+        if (value == null) {
+          unsetOffset();
+        } else {
+          setOffset((Integer) value);
+        }
+        break;
+
+      case DEBUG_OPTIONS:
+        if (value == null) {
+          unsetDebugOptions();
+        } else {
+          setDebugOptions((Map<String, String>) value);
+        }
+        break;
+
+      case QUERY_OPTIONS:
+        if (value == null) {
+          unsetQueryOptions();
+        } else {
+          setQueryOptions((Map<String, String>) value);
+        }
+        break;
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+      case VERSION:
+        return getVersion();
+
+      case DATA_SOURCE:
+        return getDataSource();
+
+      case SELECT_LIST:
+        return getSelectList();
+
+      case FILTER_EXPRESSION:
+        return getFilterExpression();
+
+      case GROUP_BY_LIST:
+        return getGroupByList();
+
+      case ORDER_BY_LIST:
+        return getOrderByList();
+
+      case HAVING_EXPRESSION:
+        return getHavingExpression();
+
+      case LIMIT:
+        return getLimit();
+
+      case OFFSET:
+        return getOffset();
+
+      case DEBUG_OPTIONS:
+        return getDebugOptions();
+
+      case QUERY_OPTIONS:
+        return getQueryOptions();
+    }
+    throw new IllegalStateException();
+  }
+
+  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
+      case VERSION:
+        return isSetVersion();
+      case DATA_SOURCE:
+        return isSetDataSource();
+      case SELECT_LIST:
+        return isSetSelectList();
+      case FILTER_EXPRESSION:
+        return isSetFilterExpression();
+      case GROUP_BY_LIST:
+        return isSetGroupByList();
+      case ORDER_BY_LIST:
+        return isSetOrderByList();
+      case HAVING_EXPRESSION:
+        return isSetHavingExpression();
+      case LIMIT:
+        return isSetLimit();
+      case OFFSET:
+        return isSetOffset();
+      case DEBUG_OPTIONS:
+        return isSetDebugOptions();
+      case QUERY_OPTIONS:
+        return isSetQueryOptions();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null) {
+      return false;
+    }
+    if (that instanceof PinotQuery) {
+      return this.equals((PinotQuery) that);
+    }
+    return false;
+  }
+
+  public boolean equals(PinotQuery that) {
+    if (that == null) {
+      return false;
+    }
+
+    boolean this_present_version = true && this.isSetVersion();
+    boolean that_present_version = true && that.isSetVersion();
+    if (this_present_version || that_present_version) {
+      if (!(this_present_version && that_present_version)) {
+        return false;
+      }
+      if (this.version != that.version) {
+        return false;
+      }
+    }
+
+    boolean this_present_dataSource = true && this.isSetDataSource();
+    boolean that_present_dataSource = true && that.isSetDataSource();
+    if (this_present_dataSource || that_present_dataSource) {
+      if (!(this_present_dataSource && that_present_dataSource)) {
+        return false;
+      }
+      if (!this.dataSource.equals(that.dataSource)) {
+        return false;
+      }
+    }
+
+    boolean this_present_selectList = true && this.isSetSelectList();
+    boolean that_present_selectList = true && that.isSetSelectList();
+    if (this_present_selectList || that_present_selectList) {
+      if (!(this_present_selectList && that_present_selectList)) {
+        return false;
+      }
+      if (!this.selectList.equals(that.selectList)) {
+        return false;
+      }
+    }
+
+    boolean this_present_filterExpression = true && this.isSetFilterExpression();
+    boolean that_present_filterExpression = true && that.isSetFilterExpression();
+    if (this_present_filterExpression || that_present_filterExpression) {
+      if (!(this_present_filterExpression && that_present_filterExpression)) {
+        return false;
+      }
+      if (!this.filterExpression.equals(that.filterExpression)) {
+        return false;
+      }
+    }
+
+    boolean this_present_groupByList = true && this.isSetGroupByList();
+    boolean that_present_groupByList = true && that.isSetGroupByList();
+    if (this_present_groupByList || that_present_groupByList) {
+      if (!(this_present_groupByList && that_present_groupByList)) {
+        return false;
+      }
+      if (!this.groupByList.equals(that.groupByList)) {
+        return false;
+      }
+    }
+
+    boolean this_present_orderByList = true && this.isSetOrderByList();
+    boolean that_present_orderByList = true && that.isSetOrderByList();
+    if (this_present_orderByList || that_present_orderByList) {
+      if (!(this_present_orderByList && that_present_orderByList)) {
+        return false;
+      }
+      if (!this.orderByList.equals(that.orderByList)) {
+        return false;
+      }
+    }
+
+    boolean this_present_havingExpression = true && this.isSetHavingExpression();
+    boolean that_present_havingExpression = true && that.isSetHavingExpression();
+    if (this_present_havingExpression || that_present_havingExpression) {
+      if (!(this_present_havingExpression && that_present_havingExpression)) {
+        return false;
+      }
+      if (!this.havingExpression.equals(that.havingExpression)) {
+        return false;
+      }
+    }
+
+    boolean this_present_limit = true && this.isSetLimit();
+    boolean that_present_limit = true && that.isSetLimit();
+    if (this_present_limit || that_present_limit) {
+      if (!(this_present_limit && that_present_limit)) {
+        return false;
+      }
+      if (this.limit != that.limit) {
+        return false;
+      }
+    }
+
+    boolean this_present_offset = true && this.isSetOffset();
+    boolean that_present_offset = true && that.isSetOffset();
+    if (this_present_offset || that_present_offset) {
+      if (!(this_present_offset && that_present_offset)) {
+        return false;
+      }
+      if (this.offset != that.offset) {
+        return false;
+      }
+    }
+
+    boolean this_present_debugOptions = true && this.isSetDebugOptions();
+    boolean that_present_debugOptions = true && that.isSetDebugOptions();
+    if (this_present_debugOptions || that_present_debugOptions) {
+      if (!(this_present_debugOptions && that_present_debugOptions)) {
+        return false;
+      }
+      if (!this.debugOptions.equals(that.debugOptions)) {
+        return false;
+      }
+    }
+
+    boolean this_present_queryOptions = true && this.isSetQueryOptions();
+    boolean that_present_queryOptions = true && that.isSetQueryOptions();
+    if (this_present_queryOptions || that_present_queryOptions) {
+      if (!(this_present_queryOptions && that_present_queryOptions)) {
+        return false;
+      }
+      if (!this.queryOptions.equals(that.queryOptions)) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    List<Object> list = new ArrayList<Object>();
+
+    boolean present_version = true && (isSetVersion());
+    list.add(present_version);
+    if (present_version) {
+      list.add(version);
+    }
+
+    boolean present_dataSource = true && (isSetDataSource());
+    list.add(present_dataSource);
+    if (present_dataSource) {
+      list.add(dataSource);
+    }
+
+    boolean present_selectList = true && (isSetSelectList());
+    list.add(present_selectList);
+    if (present_selectList) {
+      list.add(selectList);
+    }
+
+    boolean present_filterExpression = true && (isSetFilterExpression());
+    list.add(present_filterExpression);
+    if (present_filterExpression) {
+      list.add(filterExpression);
+    }
+
+    boolean present_groupByList = true && (isSetGroupByList());
+    list.add(present_groupByList);
+    if (present_groupByList) {
+      list.add(groupByList);
+    }
+
+    boolean present_orderByList = true && (isSetOrderByList());
+    list.add(present_orderByList);
+    if (present_orderByList) {
+      list.add(orderByList);
+    }
+
+    boolean present_havingExpression = true && (isSetHavingExpression());
+    list.add(present_havingExpression);
+    if (present_havingExpression) {
+      list.add(havingExpression);
+    }
+
+    boolean present_limit = true && (isSetLimit());
+    list.add(present_limit);
+    if (present_limit) {
+      list.add(limit);
+    }
+
+    boolean present_offset = true && (isSetOffset());
+    list.add(present_offset);
+    if (present_offset) {
+      list.add(offset);
+    }
+
+    boolean present_debugOptions = true && (isSetDebugOptions());
+    list.add(present_debugOptions);
+    if (present_debugOptions) {
+      list.add(debugOptions);
+    }
+
+    boolean present_queryOptions = true && (isSetQueryOptions());
+    list.add(present_queryOptions);
+    if (present_queryOptions) {
+      list.add(queryOptions);
+    }
+
+    return list.hashCode();
+  }
+
+  @Override
+  public int compareTo(PinotQuery other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetVersion()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.version, other.version);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetDataSource()).compareTo(other.isSetDataSource());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetDataSource()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dataSource, other.dataSource);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetSelectList()).compareTo(other.isSetSelectList());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetSelectList()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.selectList, other.selectList);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetFilterExpression()).compareTo(other.isSetFilterExpression());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetFilterExpression()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.filterExpression, other.filterExpression);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetGroupByList()).compareTo(other.isSetGroupByList());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetGroupByList()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.groupByList, other.groupByList);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetOrderByList()).compareTo(other.isSetOrderByList());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetOrderByList()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.orderByList, other.orderByList);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetHavingExpression()).compareTo(other.isSetHavingExpression());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetHavingExpression()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.havingExpression, other.havingExpression);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetLimit()).compareTo(other.isSetLimit());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetLimit()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.limit, other.limit);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetOffset()).compareTo(other.isSetOffset());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetOffset()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.offset, other.offset);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetDebugOptions()).compareTo(other.isSetDebugOptions());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetDebugOptions()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.debugOptions, other.debugOptions);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetQueryOptions()).compareTo(other.isSetQueryOptions());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetQueryOptions()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryOptions, other.queryOptions);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot)
+      throws org.apache.thrift.TException {
+    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot)
+      throws org.apache.thrift.TException {
+    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("PinotQuery(");
+    boolean first = true;
+
+    if (isSetVersion()) {
+      sb.append("version:");
+      sb.append(this.version);
+      first = false;
+    }
+    if (isSetDataSource()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("dataSource:");
+      if (this.dataSource == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.dataSource);
+      }
+      first = false;
+    }
+    if (isSetSelectList()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("selectList:");
+      if (this.selectList == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.selectList);
+      }
+      first = false;
+    }
+    if (isSetFilterExpression()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("filterExpression:");
+      if (this.filterExpression == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.filterExpression);
+      }
+      first = false;
+    }
+    if (isSetGroupByList()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("groupByList:");
+      if (this.groupByList == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.groupByList);
+      }
+      first = false;
+    }
+    if (isSetOrderByList()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("orderByList:");
+      if (this.orderByList == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.orderByList);
+      }
+      first = false;
+    }
+    if (isSetHavingExpression()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("havingExpression:");
+      if (this.havingExpression == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.havingExpression);
+      }
+      first = false;
+    }
+    if (isSetLimit()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("limit:");
+      sb.append(this.limit);
+      first = false;
+    }
+    if (isSetOffset()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("offset:");
+      sb.append(this.offset);
+      first = false;
+    }
+    if (isSetDebugOptions()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("debugOptions:");
+      if (this.debugOptions == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.debugOptions);
+      }
+      first = false;
+    }
+    if (isSetQueryOptions()) {
+      if (!first) {
+        sb.append(", ");
+      }
+      sb.append("queryOptions:");
+      if (this.queryOptions == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.queryOptions);
+      }
+      first = false;
+    }
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate()
+      throws org.apache.thrift.TException {
+    // check for required fields
+    // check for sub-struct validity
+    if (dataSource != null) {
+      dataSource.validate();
+    }
+  }
+
+  private void writeObject(java.io.ObjectOutputStream out)
+      throws java.io.IOException {
+    try {
+      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private void readObject(java.io.ObjectInputStream in)
+      throws java.io.IOException, ClassNotFoundException {
+    try {
+      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+      __isset_bitfield = 0;
+      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private static class PinotQueryStandardSchemeFactory implements SchemeFactory {
+    public PinotQueryStandardScheme getScheme() {
+      return new PinotQueryStandardScheme();
+    }
+  }
+
+  private static class PinotQueryStandardScheme extends StandardScheme<PinotQuery> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, PinotQuery struct)
+        throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TField schemeField;
+      iprot.readStructBegin();
+      while (true) {
+        schemeField = iprot.readFieldBegin();
+        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+          break;
+        }
+        switch (schemeField.id) {
+          case 1: // VERSION
+            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+              struct.version = iprot.readI32();
+              struct.setVersionIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // DATA_SOURCE
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.dataSource = new DataSource();
+              struct.dataSource.read(iprot);
+              struct.setDataSourceIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 3: // SELECT_LIST
+            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
+              {
+                org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
+                struct.selectList = new ArrayList<Expression>(_list0.size);
+                Expression _elem1;
+                for (int _i2 = 0; _i2 < _list0.size; ++_i2) {
+                  _elem1 = new Expression();
+                  _elem1.read(iprot);
+                  struct.selectList.add(_elem1);
+                }
+                iprot.readListEnd();
+              }
+              struct.setSelectListIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 4: // FILTER_EXPRESSION
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.filterExpression = new Expression();
+              struct.filterExpression.read(iprot);
+              struct.setFilterExpressionIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 5: // GROUP_BY_LIST
+            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
+              {
+                org.apache.thrift.protocol.TList _list3 = iprot.readListBegin();
+                struct.groupByList = new ArrayList<Expression>(_list3.size);
+                Expression _elem4;
+                for (int _i5 = 0; _i5 < _list3.size; ++_i5) {
+                  _elem4 = new Expression();
+                  _elem4.read(iprot);
+                  struct.groupByList.add(_elem4);
+                }
+                iprot.readListEnd();
+              }
+              struct.setGroupByListIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 6: // ORDER_BY_LIST
+            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
+              {
+                org.apache.thrift.protocol.TList _list6 = iprot.readListBegin();
+                struct.orderByList = new ArrayList<Expression>(_list6.size);
+                Expression _elem7;
+                for (int _i8 = 0; _i8 < _list6.size; ++_i8) {
+                  _elem7 = new Expression();
+                  _elem7.read(iprot);
+                  struct.orderByList.add(_elem7);
+                }
+                iprot.readListEnd();
+              }
+              struct.setOrderByListIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 7: // HAVING_EXPRESSION
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.havingExpression = new Expression();
+              struct.havingExpression.read(iprot);
+              struct.setHavingExpressionIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 8: // LIMIT
+            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+              struct.limit = iprot.readI32();
+              struct.setLimitIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 9: // OFFSET
+            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+              struct.offset = iprot.readI32();
+              struct.setOffsetIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 10: // DEBUG_OPTIONS
+            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
+              {
+                org.apache.thrift.protocol.TMap _map9 = iprot.readMapBegin();
+                struct.debugOptions = new HashMap<String, String>(2 * _map9.size);
+                String _key10;
+                String _val11;
+                for (int _i12 = 0; _i12 < _map9.size; ++_i12) {
+                  _key10 = iprot.readString();
+                  _val11 = iprot.readString();
+                  struct.debugOptions.put(_key10, _val11);
+                }
+                iprot.readMapEnd();
+              }
+              struct.setDebugOptionsIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 11: // QUERY_OPTIONS
+            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
+              {
+                org.apache.thrift.protocol.TMap _map13 = iprot.readMapBegin();
+                struct.queryOptions = new HashMap<String, String>(2 * _map13.size);
+                String _key14;
+                String _val15;
+                for (int _i16 = 0; _i16 < _map13.size; ++_i16) {
+                  _key14 = iprot.readString();
+                  _val15 = iprot.readString();
+                  struct.queryOptions.put(_key14, _val15);
+                }
+                iprot.readMapEnd();
+              }
+              struct.setQueryOptionsIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          default:
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+        }
+        iprot.readFieldEnd();
+      }
+      iprot.readStructEnd();
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, PinotQuery struct)
+        throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.isSetVersion()) {
+        oprot.writeFieldBegin(VERSION_FIELD_DESC);
+        oprot.writeI32(struct.version);
+        oprot.writeFieldEnd();
+      }
+      if (struct.dataSource != null) {
+        if (struct.isSetDataSource()) {
+          oprot.writeFieldBegin(DATA_SOURCE_FIELD_DESC);
+          struct.dataSource.write(oprot);
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.selectList != null) {
+        if (struct.isSetSelectList()) {
+          oprot.writeFieldBegin(SELECT_LIST_FIELD_DESC);
+          {
+            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT,
+                struct.selectList.size()));
+            for (Expression _iter17 : struct.selectList) {
+              _iter17.write(oprot);
+            }
+            oprot.writeListEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.filterExpression != null) {
+        if (struct.isSetFilterExpression()) {
+          oprot.writeFieldBegin(FILTER_EXPRESSION_FIELD_DESC);
+          struct.filterExpression.write(oprot);
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.groupByList != null) {
+        if (struct.isSetGroupByList()) {
+          oprot.writeFieldBegin(GROUP_BY_LIST_FIELD_DESC);
+          {
+            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT,
+                struct.groupByList.size()));
+            for (Expression _iter18 : struct.groupByList) {
+              _iter18.write(oprot);
+            }
+            oprot.writeListEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.orderByList != null) {
+        if (struct.isSetOrderByList()) {
+          oprot.writeFieldBegin(ORDER_BY_LIST_FIELD_DESC);
+          {
+            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT,
+                struct.orderByList.size()));
+            for (Expression _iter19 : struct.orderByList) {
+              _iter19.write(oprot);
+            }
+            oprot.writeListEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.havingExpression != null) {
+        if (struct.isSetHavingExpression()) {
+          oprot.writeFieldBegin(HAVING_EXPRESSION_FIELD_DESC);
+          struct.havingExpression.write(oprot);
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.isSetLimit()) {
+        oprot.writeFieldBegin(LIMIT_FIELD_DESC);
+        oprot.writeI32(struct.limit);
+        oprot.writeFieldEnd();
+      }
+      if (struct.isSetOffset()) {
+        oprot.writeFieldBegin(OFFSET_FIELD_DESC);
+        oprot.writeI32(struct.offset);
+        oprot.writeFieldEnd();
+      }
+      if (struct.debugOptions != null) {
+        if (struct.isSetDebugOptions()) {
+          oprot.writeFieldBegin(DEBUG_OPTIONS_FIELD_DESC);
+          {
+            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
+                org.apache.thrift.protocol.TType.STRING, struct.debugOptions.size()));
+            for (Map.Entry<String, String> _iter20 : struct.debugOptions.entrySet()) {
+              oprot.writeString(_iter20.getKey());
+              oprot.writeString(_iter20.getValue());
+            }
+            oprot.writeMapEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.queryOptions != null) {
+        if (struct.isSetQueryOptions()) {
+          oprot.writeFieldBegin(QUERY_OPTIONS_FIELD_DESC);
+          {
+            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
+                org.apache.thrift.protocol.TType.STRING, struct.queryOptions.size()));
+            for (Map.Entry<String, String> _iter21 : struct.queryOptions.entrySet()) {
+              oprot.writeString(_iter21.getKey());
+              oprot.writeString(_iter21.getValue());
+            }
+            oprot.writeMapEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+  }
+
+  private static class PinotQueryTupleSchemeFactory implements SchemeFactory {
+    public PinotQueryTupleScheme getScheme() {
+      return new PinotQueryTupleScheme();
+    }
+  }
+
+  private static class PinotQueryTupleScheme extends TupleScheme<PinotQuery> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, PinotQuery struct)
+        throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      BitSet optionals = new BitSet();
+      if (struct.isSetVersion()) {
+        optionals.set(0);
+      }
+      if (struct.isSetDataSource()) {
+        optionals.set(1);
+      }
+      if (struct.isSetSelectList()) {
+        optionals.set(2);
+      }
+      if (struct.isSetFilterExpression()) {
+        optionals.set(3);
+      }
+      if (struct.isSetGroupByList()) {
+        optionals.set(4);
+      }
+      if (struct.isSetOrderByList()) {
+        optionals.set(5);
+      }
+      if (struct.isSetHavingExpression()) {
+        optionals.set(6);
+      }
+      if (struct.isSetLimit()) {
+        optionals.set(7);
+      }
+      if (struct.isSetOffset()) {
+        optionals.set(8);
+      }
+      if (struct.isSetDebugOptions()) {
+        optionals.set(9);
+      }
+      if (struct.isSetQueryOptions()) {
+        optionals.set(10);
+      }
+      oprot.writeBitSet(optionals, 11);
+      if (struct.isSetVersion()) {
+        oprot.writeI32(struct.version);
+      }
+      if (struct.isSetDataSource()) {
+        struct.dataSource.write(oprot);
+      }
+      if (struct.isSetSelectList()) {
+        {
+          oprot.writeI32(struct.selectList.size());
+          for (Expression _iter22 : struct.selectList) {
+            _iter22.write(oprot);
+          }
+        }
+      }
+      if (struct.isSetFilterExpression()) {
+        struct.filterExpression.write(oprot);
+      }
+      if (struct.isSetGroupByList()) {
+        {
+          oprot.writeI32(struct.groupByList.size());
+          for (Expression _iter23 : struct.groupByList) {
+            _iter23.write(oprot);
+          }
+        }
+      }
+      if (struct.isSetOrderByList()) {
+        {
+          oprot.writeI32(struct.orderByList.size());
+          for (Expression _iter24 : struct.orderByList) {
+            _iter24.write(oprot);
+          }
+        }
+      }
+      if (struct.isSetHavingExpression()) {
+        struct.havingExpression.write(oprot);
+      }
+      if (struct.isSetLimit()) {
+        oprot.writeI32(struct.limit);
+      }
+      if (struct.isSetOffset()) {
+        oprot.writeI32(struct.offset);
+      }
+      if (struct.isSetDebugOptions()) {
+        {
+          oprot.writeI32(struct.debugOptions.size());
+          for (Map.Entry<String, String> _iter25 : struct.debugOptions.entrySet()) {
+            oprot.writeString(_iter25.getKey());
+            oprot.writeString(_iter25.getValue());
+          }
+        }
+      }
+      if (struct.isSetQueryOptions()) {
+        {
+          oprot.writeI32(struct.queryOptions.size());
+          for (Map.Entry<String, String> _iter26 : struct.queryOptions.entrySet()) {
+            oprot.writeString(_iter26.getKey());
+            oprot.writeString(_iter26.getValue());
+          }
+        }
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, PinotQuery struct)
+        throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      BitSet incoming = iprot.readBitSet(11);
+      if (incoming.get(0)) {
+        struct.version = iprot.readI32();
+        struct.setVersionIsSet(true);
+      }
+      if (incoming.get(1)) {
+        struct.dataSource = new DataSource();
+        struct.dataSource.read(iprot);
+        struct.setDataSourceIsSet(true);
+      }
+      if (incoming.get(2)) {
+        {
+          org.apache.thrift.protocol.TList _list27 =
+              new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.selectList = new ArrayList<Expression>(_list27.size);
+          Expression _elem28;
+          for (int _i29 = 0; _i29 < _list27.size; ++_i29) {
+            _elem28 = new Expression();
+            _elem28.read(iprot);
+            struct.selectList.add(_elem28);
+          }
+        }
+        struct.setSelectListIsSet(true);
+      }
+      if (incoming.get(3)) {
+        struct.filterExpression = new Expression();
+        struct.filterExpression.read(iprot);
+        struct.setFilterExpressionIsSet(true);
+      }
+      if (incoming.get(4)) {
+        {
+          org.apache.thrift.protocol.TList _list30 =
+              new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.groupByList = new ArrayList<Expression>(_list30.size);
+          Expression _elem31;
+          for (int _i32 = 0; _i32 < _list30.size; ++_i32) {
+            _elem31 = new Expression();
+            _elem31.read(iprot);
+            struct.groupByList.add(_elem31);
+          }
+        }
+        struct.setGroupByListIsSet(true);
+      }
+      if (incoming.get(5)) {
+        {
+          org.apache.thrift.protocol.TList _list33 =
+              new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.orderByList = new ArrayList<Expression>(_list33.size);
+          Expression _elem34;
+          for (int _i35 = 0; _i35 < _list33.size; ++_i35) {
+            _elem34 = new Expression();
+            _elem34.read(iprot);
+            struct.orderByList.add(_elem34);
+          }
+        }
+        struct.setOrderByListIsSet(true);
+      }
+      if (incoming.get(6)) {
+        struct.havingExpression = new Expression();
+        struct.havingExpression.read(iprot);
+        struct.setHavingExpressionIsSet(true);
+      }
+      if (incoming.get(7)) {
+        struct.limit = iprot.readI32();
+        struct.setLimitIsSet(true);
+      }
+      if (incoming.get(8)) {
+        struct.offset = iprot.readI32();
+        struct.setOffsetIsSet(true);
+      }
+      if (incoming.get(9)) {
+        {
+          org.apache.thrift.protocol.TMap _map36 =
+              new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
+                  org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+          struct.debugOptions = new HashMap<String, String>(2 * _map36.size);
+          String _key37;
+          String _val38;
+          for (int _i39 = 0; _i39 < _map36.size; ++_i39) {
+            _key37 = iprot.readString();
+            _val38 = iprot.readString();
+            struct.debugOptions.put(_key37, _val38);
+          }
+        }
+        struct.setDebugOptionsIsSet(true);
+      }
+      if (incoming.get(10)) {
+        {
+          org.apache.thrift.protocol.TMap _map40 =
+              new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
+                  org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+          struct.queryOptions = new HashMap<String, String>(2 * _map40.size);
+          String _key41;
+          String _val42;
+          for (int _i43 = 0; _i43 < _map40.size; ++_i43) {
+            _key41 = iprot.readString();
+            _val42 = iprot.readString();
+            struct.queryOptions.put(_key41, _val42);
+          }
+        }
+        struct.setQueryOptionsIsSet(true);
+      }
+    }
+  }
+}
+
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java b/pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java
index ab4b6d4..6db22a0 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/QuerySource.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -46,7 +46,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * Query source
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class QuerySource implements org.apache.thrift.TBase<QuerySource, QuerySource._Fields>, java.io.Serializable, Cloneable, Comparable<QuerySource> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("QuerySource");
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/QueryType.java b/pinot-common/src/main/java/org/apache/pinot/common/request/QueryType.java
index b0521a2..faf7afd 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/QueryType.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/QueryType.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -47,7 +47,7 @@ import org.apache.thrift.scheme.TupleScheme;
  *  Query type
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-8-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class QueryType implements org.apache.thrift.TBase<QueryType, QueryType._Fields>, java.io.Serializable, Cloneable, Comparable<QueryType> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("QueryType");
@@ -372,19 +372,19 @@ public class QueryType implements org.apache.thrift.TBase<QueryType, QueryType._
   public Object getFieldValue(_Fields field) {
     switch (field) {
       case HAS_SELECTION:
-        return Boolean.valueOf(isHasSelection());
+        return isHasSelection();
 
       case HAS_FILTER:
-        return Boolean.valueOf(isHasFilter());
+        return isHasFilter();
 
       case HAS_AGGREGATION:
-        return Boolean.valueOf(isHasAggregation());
+        return isHasAggregation();
 
       case HAS_GROUP_BY:
-        return Boolean.valueOf(isHasGroup_by());
+        return isHasGroup_by();
 
       case HAS_HAVING:
-        return Boolean.valueOf(isHasHaving());
+        return isHasHaving();
     }
     throw new IllegalStateException();
   }
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/Selection.java b/pinot-common/src/main/java/org/apache/pinot/common/request/Selection.java
index 35a6a1a..caea546 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/Selection.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/Selection.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -47,7 +47,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * Selection
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class Selection implements org.apache.thrift.TBase<Selection, Selection._Fields>, java.io.Serializable, Cloneable, Comparable<Selection> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("Selection");
@@ -378,10 +378,10 @@ public class Selection implements org.apache.thrift.TBase<Selection, Selection._
         return getSelectionSortSequence();
 
       case OFFSET:
-        return Integer.valueOf(getOffset());
+        return getOffset();
 
       case SIZE:
-        return Integer.valueOf(getSize());
+        return getSize();
     }
     throw new IllegalStateException();
   }
@@ -657,12 +657,12 @@ public class Selection implements org.apache.thrift.TBase<Selection, Selection._
           case 1: // SELECTION_COLUMNS
             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
               {
-                org.apache.thrift.protocol.TList _list52 = iprot.readListBegin();
-                struct.selectionColumns = new ArrayList<String>(_list52.size);
-                String _elem53;
-                for (int _i54 = 0; _i54 < _list52.size; ++_i54) {
-                  _elem53 = iprot.readString();
-                  struct.selectionColumns.add(_elem53);
+                org.apache.thrift.protocol.TList _list78 = iprot.readListBegin();
+                struct.selectionColumns = new ArrayList<String>(_list78.size);
+                String _elem79;
+                for (int _i80 = 0; _i80 < _list78.size; ++_i80) {
+                  _elem79 = iprot.readString();
+                  struct.selectionColumns.add(_elem79);
                 }
                 iprot.readListEnd();
               }
@@ -674,13 +674,13 @@ public class Selection implements org.apache.thrift.TBase<Selection, Selection._
           case 2: // SELECTION_SORT_SEQUENCE
             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
               {
-                org.apache.thrift.protocol.TList _list55 = iprot.readListBegin();
-                struct.selectionSortSequence = new ArrayList<SelectionSort>(_list55.size);
-                SelectionSort _elem56;
-                for (int _i57 = 0; _i57 < _list55.size; ++_i57) {
-                  _elem56 = new SelectionSort();
-                  _elem56.read(iprot);
-                  struct.selectionSortSequence.add(_elem56);
+                org.apache.thrift.protocol.TList _list81 = iprot.readListBegin();
+                struct.selectionSortSequence = new ArrayList<SelectionSort>(_list81.size);
+                SelectionSort _elem82;
+                for (int _i83 = 0; _i83 < _list81.size; ++_i83) {
+                  _elem82 = new SelectionSort();
+                  _elem82.read(iprot);
+                  struct.selectionSortSequence.add(_elem82);
                 }
                 iprot.readListEnd();
               }
@@ -725,8 +725,8 @@ public class Selection implements org.apache.thrift.TBase<Selection, Selection._
           {
             oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING,
                 struct.selectionColumns.size()));
-            for (String _iter58 : struct.selectionColumns) {
-              oprot.writeString(_iter58);
+            for (String _iter84 : struct.selectionColumns) {
+              oprot.writeString(_iter84);
             }
             oprot.writeListEnd();
           }
@@ -739,8 +739,8 @@ public class Selection implements org.apache.thrift.TBase<Selection, Selection._
           {
             oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT,
                 struct.selectionSortSequence.size()));
-            for (SelectionSort _iter59 : struct.selectionSortSequence) {
-              _iter59.write(oprot);
+            for (SelectionSort _iter85 : struct.selectionSortSequence) {
+              _iter85.write(oprot);
             }
             oprot.writeListEnd();
           }
@@ -791,16 +791,16 @@ public class Selection implements org.apache.thrift.TBase<Selection, Selection._
       if (struct.isSetSelectionColumns()) {
         {
           oprot.writeI32(struct.selectionColumns.size());
-          for (String _iter60 : struct.selectionColumns) {
-            oprot.writeString(_iter60);
+          for (String _iter86 : struct.selectionColumns) {
+            oprot.writeString(_iter86);
           }
         }
       }
       if (struct.isSetSelectionSortSequence()) {
         {
           oprot.writeI32(struct.selectionSortSequence.size());
-          for (SelectionSort _iter61 : struct.selectionSortSequence) {
-            _iter61.write(oprot);
+          for (SelectionSort _iter87 : struct.selectionSortSequence) {
+            _iter87.write(oprot);
           }
         }
       }
@@ -819,27 +819,27 @@ public class Selection implements org.apache.thrift.TBase<Selection, Selection._
       BitSet incoming = iprot.readBitSet(4);
       if (incoming.get(0)) {
         {
-          org.apache.thrift.protocol.TList _list62 =
+          org.apache.thrift.protocol.TList _list88 =
               new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-          struct.selectionColumns = new ArrayList<String>(_list62.size);
-          String _elem63;
-          for (int _i64 = 0; _i64 < _list62.size; ++_i64) {
-            _elem63 = iprot.readString();
-            struct.selectionColumns.add(_elem63);
+          struct.selectionColumns = new ArrayList<String>(_list88.size);
+          String _elem89;
+          for (int _i90 = 0; _i90 < _list88.size; ++_i90) {
+            _elem89 = iprot.readString();
+            struct.selectionColumns.add(_elem89);
           }
         }
         struct.setSelectionColumnsIsSet(true);
       }
       if (incoming.get(1)) {
         {
-          org.apache.thrift.protocol.TList _list65 =
+          org.apache.thrift.protocol.TList _list91 =
               new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-          struct.selectionSortSequence = new ArrayList<SelectionSort>(_list65.size);
-          SelectionSort _elem66;
-          for (int _i67 = 0; _i67 < _list65.size; ++_i67) {
-            _elem66 = new SelectionSort();
-            _elem66.read(iprot);
-            struct.selectionSortSequence.add(_elem66);
+          struct.selectionSortSequence = new ArrayList<SelectionSort>(_list91.size);
+          SelectionSort _elem92;
+          for (int _i93 = 0; _i93 < _list91.size; ++_i93) {
+            _elem92 = new SelectionSort();
+            _elem92.read(iprot);
+            struct.selectionSortSequence.add(_elem92);
           }
         }
         struct.setSelectionSortSequenceIsSet(true);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/request/SelectionSort.java b/pinot-common/src/main/java/org/apache/pinot/common/request/SelectionSort.java
index db74456..feb3da7 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/request/SelectionSort.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/request/SelectionSort.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -48,7 +48,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * The results can be sorted based on one or multiple columns
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class SelectionSort implements org.apache.thrift.TBase<SelectionSort, SelectionSort._Fields>, java.io.Serializable, Cloneable, Comparable<SelectionSort> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("SelectionSort");
@@ -246,7 +246,7 @@ public class SelectionSort implements org.apache.thrift.TBase<SelectionSort, Sel
         return getColumn();
 
       case IS_ASC:
-        return Boolean.valueOf(isIsAsc());
+        return isIsAsc();
     }
     throw new IllegalStateException();
   }
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/response/ProcessingException.java b/pinot-common/src/main/java/org/apache/pinot/common/response/ProcessingException.java
index a0a8724..1338363 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/response/ProcessingException.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/response/ProcessingException.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 /**
- * Autogenerated by Thrift Compiler (0.9.2)
+ * Autogenerated by Thrift Compiler (0.9.3)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -47,7 +47,7 @@ import org.apache.thrift.scheme.TupleScheme;
  * Processing exception
  *
  */
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-24")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-06-06")
 public class ProcessingException extends TException implements org.apache.thrift.TBase<ProcessingException, ProcessingException._Fields>, java.io.Serializable, Cloneable, Comparable<ProcessingException> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
       new org.apache.thrift.protocol.TStruct("ProcessingException");
@@ -248,7 +248,7 @@ public class ProcessingException extends TException implements org.apache.thrift
   public Object getFieldValue(_Fields field) {
     switch (field) {
       case ERROR_CODE:
-        return Integer.valueOf(getErrorCode());
+        return getErrorCode();
 
       case MESSAGE:
         return getMessage();
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java
index f914714..1b3f110 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java
@@ -27,16 +27,31 @@ import java.util.Set;
 import java.util.Stack;
 import org.apache.commons.lang.mutable.MutableInt;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.ExpressionType;
 import org.apache.pinot.common.request.FilterQuery;
 import org.apache.pinot.common.request.FilterQueryMap;
+import org.apache.pinot.common.request.Function;
 import org.apache.pinot.common.request.HavingFilterQuery;
 import org.apache.pinot.common.request.HavingFilterQueryMap;
+import org.apache.pinot.common.request.Identifier;
+import org.apache.pinot.common.request.Literal;
 import org.apache.pinot.common.request.Selection;
 import org.apache.pinot.common.request.SelectionSort;
 import org.apache.pinot.common.request.transform.TransformExpressionTree;
+import org.apache.pinot.pql.parsers.pql2.ast.AstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.FloatingPointLiteralAstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.FunctionCallAstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.IdentifierAstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.IntegerLiteralAstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.LiteralAstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.PredicateAstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.StringLiteralAstNode;
 
 
 public class RequestUtils {
+  private static String DELIMTER = "\t\t";
+
   private RequestUtils() {
   }
 
@@ -56,6 +71,50 @@ public class RequestUtils {
     request.setFilterSubQueryMap(mp);
   }
 
+  /**
+   * Creates Expression from identifier
+   * @param identifier
+   * @return
+   */
+  public static Expression createIdentifierExpression(String identifier) {
+    Expression expression = new Expression(ExpressionType.IDENTIFIER);
+    expression.setIdentifier(new Identifier(identifier));
+    return expression;
+  }
+
+  /**
+   * Creates Literal Expression from LiteralAstNode.
+   * @param value
+   * @return
+   */
+  public static Expression createLiteralExpression(LiteralAstNode value) {
+    Expression expression = new Expression(ExpressionType.LITERAL);
+    Literal literal = new Literal();
+    if(value instanceof StringLiteralAstNode) {
+      literal.setStringValue(((StringLiteralAstNode)value).getText());
+    }
+    if(value instanceof IntegerLiteralAstNode) {
+      literal.setLongValue(((IntegerLiteralAstNode)value).getValue());
+    }
+    if(value instanceof FloatingPointLiteralAstNode) {
+      literal.setDoubleValue(((FloatingPointLiteralAstNode)value).getValue());
+    }
+    expression.setLiteral(literal);
+    return expression;
+  }
+
+  /**
+   * Create Function Expression given a functionName
+   * @param functionName
+   * @return
+   */
+  public static Expression createFunctionExpression(String functionName) {
+    Expression expression = new Expression(ExpressionType.FUNCTION);
+    Function function = new Function(functionName);
+    expression.setFunctionCall(function);
+    return expression;
+  }
+
   public static void generateFilterFromTree(HavingQueryTree filterQueryTree, BrokerRequest request) {
     Map<Integer, HavingFilterQuery> filterQueryMap = new HashMap<>();
     MutableInt currentId = new MutableInt(0);
@@ -75,11 +134,9 @@ public class RequestUtils {
     final List<Integer> f = new ArrayList<>();
     if (null != tree.getChildren()) {
       for (final FilterQueryTree c : tree.getChildren()) {
-        int childNodeId = currentId.intValue();
-        currentId.increment();
-
-        f.add(childNodeId);
         final FilterQuery q = traverseFilterQueryAndPopulateMap(c, filterQueryMap, currentId);
+        int childNodeId = q.getId();
+        f.add(childNodeId);
         filterQueryMap.put(childNodeId, q);
       }
     }
@@ -204,4 +261,38 @@ public class RequestUtils {
     }
     return selectionColumns;
   }
+
+  /**
+   * Returns the expression from a given {@link AstNode}, which can be one of the following:
+   * <ul>
+   *   <li> {@link FunctionCallAstNode}</li>
+   *   <li> {@link LiteralAstNode}</li>
+   *   <li> {@link PredicateAstNode}</li>
+   * </ul>
+   *
+   * @return Expression
+   */
+  public static Expression getExpression(AstNode astNode) {
+    if (astNode instanceof IdentifierAstNode) {
+      // Column name
+      return createIdentifierExpression(((IdentifierAstNode) astNode).getName());
+    } else if (astNode instanceof FunctionCallAstNode) {
+      // Function expression
+      Expression expression = createFunctionExpression(((FunctionCallAstNode) astNode).getName());
+      Function func = expression.getFunctionCall();
+      final List<? extends AstNode> operandsAstNodes = astNode.getChildren();
+      if (operandsAstNodes != null) {
+        for (AstNode child : operandsAstNodes) {
+          func.addToOperands(getExpression(child));
+        }
+      }
+      return expression;
+    } else if (astNode instanceof LiteralAstNode) {
+      return createLiteralExpression(((LiteralAstNode) astNode));
+    } else if (astNode instanceof PredicateAstNode) {
+      return ((PredicateAstNode) astNode).buildFilterExpression();
+    } else {
+      throw new IllegalStateException("Cannot get expression from " + astNode.getClass().getSimpleName());
+    }
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java
new file mode 100644
index 0000000..7724d87
--- /dev/null
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/PinotQuery2BrokerRequestConverter.java
@@ -0,0 +1,354 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.pinot.pql.parsers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.request.AggregationInfo;
+import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.ExpressionType;
+import org.apache.pinot.common.request.FilterOperator;
+import org.apache.pinot.common.request.FilterQuery;
+import org.apache.pinot.common.request.FilterQueryMap;
+import org.apache.pinot.common.request.Function;
+import org.apache.pinot.common.request.GroupBy;
+import org.apache.pinot.common.request.Literal;
+import org.apache.pinot.common.request.PinotQuery;
+import org.apache.pinot.common.request.QuerySource;
+import org.apache.pinot.common.request.Selection;
+import org.apache.pinot.common.request.SelectionSort;
+import org.apache.pinot.pql.parsers.pql2.ast.FilterKind;
+
+
+public class PinotQuery2BrokerRequestConverter {
+
+  static Map<FilterKind, FilterOperator> filterOperatorMapping;
+
+  public BrokerRequest convert(PinotQuery pinotQuery) {
+    BrokerRequest brokerRequest = new BrokerRequest();
+
+    //Query Source
+    QuerySource querySource = new QuerySource();
+    querySource.setTableName(pinotQuery.getDataSource().getTableName());
+    brokerRequest.setQuerySource(querySource);
+
+    convertFilter(pinotQuery, brokerRequest);
+
+    //Handle select list
+    convertSelectList(pinotQuery, brokerRequest);
+
+    //Handle order by
+    convertOrderBy(pinotQuery, brokerRequest);
+
+    //Handle group by
+    convertGroupBy(pinotQuery, brokerRequest);
+
+    //TODO: these should not be part of the query?
+    //brokerRequest.setEnableTrace();
+    //brokerRequest.setDebugOptions();
+    brokerRequest.setQueryOptions(pinotQuery.getQueryOptions());
+    //brokerRequest.setBucketHashKey();
+    //brokerRequest.setDuration();
+
+    return brokerRequest;
+  }
+
+  private void convertOrderBy(PinotQuery pinotQuery, BrokerRequest brokerRequest) {
+    if (brokerRequest.getSelections() == null || pinotQuery.getOrderByList() == null) {
+      return;
+    }
+    List<SelectionSort> sortSequenceList = new ArrayList<>();
+    final List<Expression> orderByList = pinotQuery.getOrderByList();
+    for (Expression orderByExpr : orderByList) {
+      SelectionSort selectionSort = new SelectionSort();
+      //order by is always a function (ASC or DESC)
+      Function functionCall = orderByExpr.getFunctionCall();
+      if (functionCall.getOperator().equalsIgnoreCase("ASC")) {
+        selectionSort.setIsAsc(true);
+      } else {
+        selectionSort.setIsAsc(false);
+      }
+      selectionSort.setColumn(standardizeExpression(functionCall.getOperands().get(0), true));
+      sortSequenceList.add(selectionSort);
+    }
+    if (!sortSequenceList.isEmpty()) {
+      brokerRequest.getSelections().setSelectionSortSequence(sortSequenceList);
+    }
+  }
+
+  private void convertGroupBy(PinotQuery pinotQuery, BrokerRequest brokerRequest) {
+    List<Expression> groupByList = pinotQuery.getGroupByList();
+    if (groupByList != null && groupByList.size() > 0) {
+      GroupBy groupBy = new GroupBy();
+      for (Expression expression : groupByList) {
+        String expressionStr = standardizeExpression(expression, true);
+        groupBy.addToExpressions(expressionStr);
+      }
+      groupBy.setTopN(pinotQuery.getLimit());
+      brokerRequest.setGroupBy(groupBy);
+    }
+  }
+
+  private void convertSelectList(PinotQuery pinotQuery, BrokerRequest brokerRequest) {
+    Selection selection = null;
+    List<AggregationInfo> aggregationInfoList = null;
+    for (Expression expression : pinotQuery.getSelectList()) {
+      ExpressionType type = expression.getType();
+      switch (type) {
+        case LITERAL:
+          if (selection == null) {
+            selection = new Selection();
+          }
+          selection.addToSelectionColumns(expression.getLiteral().getStringValue());
+          break;
+        case IDENTIFIER:
+          if (selection == null) {
+            selection = new Selection();
+          }
+          selection.addToSelectionColumns(expression.getIdentifier().getName());
+          break;
+        case FUNCTION:
+          AggregationInfo aggInfo = buildAggregationInfo(expression.getFunctionCall());
+          if (aggregationInfoList == null) {
+            aggregationInfoList = new ArrayList<>();
+          }
+          aggregationInfoList.add(aggInfo);
+          break;
+      }
+    }
+
+    if (selection != null) {
+      if (pinotQuery.isSetOffset()) {
+        selection.setOffset(pinotQuery.getOffset());
+      }
+      if (pinotQuery.isSetLimit()) {
+        selection.setSize(pinotQuery.getLimit());
+      }
+      brokerRequest.setSelections(selection);
+    }
+
+    if (aggregationInfoList != null && aggregationInfoList.size() > 0) {
+      brokerRequest.setAggregationsInfo(aggregationInfoList);
+    }
+  }
+
+  private void convertFilter(PinotQuery pinotQuery, BrokerRequest brokerRequest) {
+    Expression filterExpression = pinotQuery.getFilterExpression();
+
+    //Handle filter
+    if (filterExpression != null) {
+      FilterQuery filterQuery;
+      FilterQueryMap filterSubQueryMap = new FilterQueryMap();
+      filterQuery = traverseFilterExpression(filterExpression, filterSubQueryMap);
+      brokerRequest.setFilterQuery(filterQuery);
+      brokerRequest.setFilterSubQueryMap(filterSubQueryMap);
+    }
+  }
+
+  private String standardizeExpression(Expression expression, boolean treatLiteralAsIdentifier) {
+    return standardizeExpression(expression, treatLiteralAsIdentifier, false);
+  }
+
+  private String standardizeExpression(Expression expression, boolean treatLiteralAsIdentifier,
+      boolean forceSingleQuoteOnNonStringLiteral) {
+    switch (expression.getType()) {
+      case LITERAL:
+        Literal literal = expression.getLiteral();
+        // Force single quote on non-string literal inside a function.
+        if (forceSingleQuoteOnNonStringLiteral && !literal.isSetStringValue()) {
+          return "'" + literal.getFieldValue() + "'";
+        }
+        if (treatLiteralAsIdentifier || !literal.isSetStringValue()) {
+          return literal.getFieldValue().toString();
+        } else {
+          return "'" + literal.getFieldValue() + "'";
+        }
+      case IDENTIFIER:
+        return expression.getIdentifier().getName();
+      case FUNCTION:
+        Function functionCall = expression.getFunctionCall();
+        String functionString = standardizeFunction(functionCall);
+        return functionString;
+      default:
+        throw new UnsupportedOperationException("Unknown Expression type: " + expression.getType());
+    }
+  }
+
+  private String standardizeFunction(Function functionCall) {
+    StringBuilder sb = new StringBuilder();
+    sb.append(functionCall.getOperator().toLowerCase());
+    sb.append("(");
+    String delim = "";
+    for (Expression operand : functionCall.getOperands()) {
+      sb.append(delim);
+      sb.append(standardizeExpression(operand, false, true));
+      delim = ",";
+    }
+    sb.append(")");
+    return sb.toString();
+  }
+
+  private AggregationInfo buildAggregationInfo(Function function) {
+    List<Expression> operands = function.getOperands();
+    if (operands == null || operands.size() != 1) {
+      throw new Pql2CompilationException(
+          "Aggregation function" + function.getOperator() + " expects 1 argument. found: " + operands);
+    }
+    String functionName = function.getOperator();
+    String columnName;
+    if (functionName.equalsIgnoreCase("count")) {
+      columnName = "*";
+    } else {
+      Expression functionParam = operands.get(0);
+
+      switch (functionParam.getType()) {
+        case LITERAL:
+          columnName = functionParam.getLiteral().getStringValue();
+          break;
+        case IDENTIFIER:
+          columnName = functionParam.getIdentifier().getName();
+          break;
+        case FUNCTION:
+          columnName = standardizeExpression(functionParam, false, true);
+          break;
+        default:
+          throw new UnsupportedOperationException("Unrecognized functionParamType:" + functionParam.getType());
+      }
+    }
+    AggregationInfo aggregationInfo = new AggregationInfo();
+    aggregationInfo.setAggregationType(functionName);
+    aggregationInfo.putToAggregationParams("column", columnName);
+    aggregationInfo.setIsInSelectList(true);
+    return aggregationInfo;
+  }
+
+  private FilterQuery traverseFilterExpression(Expression filterExpression, FilterQueryMap filterSubQueryMap) {
+    FilterQuery filterQuery = new FilterQuery();
+    int id = filterSubQueryMap.getFilterQueryMapSize();
+    filterQuery.setId(id);
+    filterSubQueryMap.putToFilterQueryMap(id, filterQuery);
+    List<Integer> childFilterIds = new ArrayList<>();
+    switch (filterExpression.getType()) {
+      case LITERAL:
+        break;
+      case IDENTIFIER:
+        break;
+      case FUNCTION:
+        Function functionCall = filterExpression.getFunctionCall();
+        String operator = functionCall.getOperator();
+        FilterKind filterKind = FilterKind.valueOf(operator);
+        FilterOperator filterOperator = filterOperatorMapping.get(filterKind);
+        filterQuery.setOperator(filterOperator);
+        List<Expression> operands = functionCall.getOperands();
+        switch (filterOperator) {
+          case AND:
+          case OR:
+            for (Expression operand : operands) {
+              FilterQuery childFilter = traverseFilterExpression(operand, filterSubQueryMap);
+              childFilterIds.add(childFilter.getId());
+            }
+            break;
+          case EQUALITY:
+          case NOT:
+          case REGEXP_LIKE:
+          case NOT_IN:
+          case IN:
+            //first operand is the always the column
+            String column = null;
+            //remaining operands are arguments to the function
+            List<String> valueList = new ArrayList<>();
+            for (int i = 0; i < operands.size(); i++) {
+              Expression operand = operands.get(i);
+              if (i == 0) {
+                column = standardizeExpression(operand, false);
+              } else {
+                valueList.add(standardizeExpression(operand, true));
+              }
+            }
+            filterQuery.setColumn(column);
+            filterQuery.setValue(valueList);
+            break;
+          case RANGE:
+            handleRange(filterQuery, filterKind, operands);
+            break;
+          default:
+            throw new UnsupportedOperationException("Filter UDF not supported");
+        }
+        break;
+    }
+    filterQuery.setNestedFilterQueryIds(childFilterIds);
+    return filterQuery;
+  }
+
+  private void handleRange(FilterQuery filterQuery, FilterKind filterKind, List<Expression> operands) {
+
+    filterQuery.setColumn(standardizeExpression(operands.get(0), false));
+
+    String rangeExpression;
+    //PQL does not quote the string literals when we create expression
+    boolean treatLiteralAsIdentifier = true;
+
+    if (FilterKind.LESS_THAN == filterKind) {
+
+      String value = standardizeExpression(operands.get(1), treatLiteralAsIdentifier);
+      rangeExpression = "(*\t\t" + value + ")";
+    } else if (FilterKind.LESS_THAN_OR_EQUAL == filterKind) {
+
+      String value = standardizeExpression(operands.get(1), treatLiteralAsIdentifier);
+      rangeExpression = "(*\t\t" + value + "]";
+    } else if (FilterKind.GREATER_THAN == filterKind) {
+
+      String value = standardizeExpression(operands.get(1), treatLiteralAsIdentifier);
+      rangeExpression = "(" + value + "\t\t*)";
+    } else if (FilterKind.GREATER_THAN_OR_EQUAL == filterKind) {
+
+      String value = standardizeExpression(operands.get(1), treatLiteralAsIdentifier);
+      rangeExpression = "[" + value + "\t\t*)";
+    } else if (FilterKind.BETWEEN == filterKind) {
+
+      String left = standardizeExpression(operands.get(1), treatLiteralAsIdentifier);
+      String right = standardizeExpression(operands.get(2), treatLiteralAsIdentifier);
+      rangeExpression = "[" + left + "\t\t" + right + "]";
+    } else {
+      throw new UnsupportedOperationException("Unknown Filter Kind:" + filterKind);
+    }
+    List<String> valueList = new ArrayList<>();
+    valueList.add(rangeExpression);
+    filterQuery.setValue(valueList);
+  }
+
+  static {
+    filterOperatorMapping = new HashMap<>();
+    filterOperatorMapping.put(FilterKind.AND, FilterOperator.AND);
+    filterOperatorMapping.put(FilterKind.OR, FilterOperator.OR);
+    filterOperatorMapping.put(FilterKind.EQUALS, FilterOperator.EQUALITY);
+    filterOperatorMapping.put(FilterKind.NOT_EQUALS, FilterOperator.NOT);
+    filterOperatorMapping.put(FilterKind.GREATER_THAN, FilterOperator.RANGE);
+    filterOperatorMapping.put(FilterKind.LESS_THAN, FilterOperator.RANGE);
+    filterOperatorMapping.put(FilterKind.GREATER_THAN_OR_EQUAL, FilterOperator.RANGE);
+    filterOperatorMapping.put(FilterKind.LESS_THAN_OR_EQUAL, FilterOperator.RANGE);
+    filterOperatorMapping.put(FilterKind.BETWEEN, FilterOperator.RANGE);
+    filterOperatorMapping.put(FilterKind.IN, FilterOperator.IN);
+    filterOperatorMapping.put(FilterKind.NOT_IN, FilterOperator.NOT_IN);
+    filterOperatorMapping.put(FilterKind.REGEXP_LIKE, FilterOperator.REGEXP_LIKE);
+  }
+}
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2Compiler.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2Compiler.java
index 8a6250a..6f63a63 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2Compiler.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/Pql2Compiler.java
@@ -18,6 +18,7 @@
  */
 package org.apache.pinot.pql.parsers;
 
+import com.google.common.annotations.VisibleForTesting;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Stack;
@@ -38,7 +39,9 @@ import org.antlr.v4.runtime.tree.ParseTree;
 import org.antlr.v4.runtime.tree.ParseTreeWalker;
 import org.apache.commons.lang.math.NumberUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.pinot.common.request.AggregationInfo;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.common.request.transform.TransformExpressionTree;
 import org.apache.pinot.pql.parsers.pql2.ast.AstNode;
 import org.apache.pinot.pql.parsers.pql2.ast.BaseAstNode;
@@ -49,6 +52,8 @@ import org.apache.pinot.pql.parsers.pql2.ast.HavingAstNode;
 import org.apache.pinot.pql.parsers.pql2.ast.InPredicateAstNode;
 import org.apache.pinot.pql.parsers.pql2.ast.OutputColumnAstNode;
 import org.apache.pinot.pql.parsers.pql2.ast.RegexpLikePredicateAstNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -57,7 +62,17 @@ import org.apache.pinot.pql.parsers.pql2.ast.RegexpLikePredicateAstNode;
 @ThreadSafe
 public class Pql2Compiler implements AbstractCompiler {
 
+  private static final Logger LOGGER = LoggerFactory.getLogger(Pql2Compiler.class);
+
+  public static boolean ENABLE_PINOT_QUERY =
+      Boolean.valueOf(System.getProperty("pinot.query.converter.enabled", "false"));
+  public static boolean VALIDATE_CONVERTER =
+      Boolean.valueOf(System.getProperty("pinot.query.converter.validate", "false"));
+  public static boolean FAIL_ON_CONVERSION_ERROR =
+      Boolean.valueOf(System.getProperty("pinot.query.converter.fail_on_error", "false"));
+
   private static class ErrorListener extends BaseErrorListener {
+
     @Override
     public void syntaxError(@Nonnull Recognizer<?, ?> recognizer, @Nullable Object offendingSymbol, int line,
         int charPositionInLine, @Nonnull String msg, @Nullable RecognitionException e) {
@@ -72,7 +87,6 @@ public class Pql2Compiler implements AbstractCompiler {
    *
    * @param expression Expression to compile
    * @return BrokerRequest
-   * @throws Pql2CompilationException
    */
   @Override
   public BrokerRequest compileToBrokerRequest(String expression)
@@ -103,6 +117,31 @@ public class Pql2Compiler implements AbstractCompiler {
 
       BrokerRequest brokerRequest = new BrokerRequest();
       rootNode.updateBrokerRequest(brokerRequest);
+      if (ENABLE_PINOT_QUERY) {
+        try {
+          PinotQuery pinotQuery = new PinotQuery();
+          rootNode.updatePinotQuery(pinotQuery);
+          if (VALIDATE_CONVERTER) {
+            PinotQuery2BrokerRequestConverter converter = new PinotQuery2BrokerRequestConverter();
+            BrokerRequest tempBrokerRequest = converter.convert(pinotQuery);
+            boolean result = compare(brokerRequest, tempBrokerRequest);
+            if (!result) {
+              LOGGER.error("Pinot query to broker request conversion failed. PQL:{}", expression);
+              if (FAIL_ON_CONVERSION_ERROR) {
+                throw new Pql2CompilationException(
+                    "Pinot query to broker request conversion failed. PQL:" + expression);
+              }
+            }
+          }
+          brokerRequest.setPinotQuery(pinotQuery);
+        } catch (Exception e) {
+          //non fatal for now.
+          LOGGER.error("Non fatal: Failed to populate pinot query and broker request. PQL:{}", expression, e);
+          if (FAIL_ON_CONVERSION_ERROR) {
+            throw e;
+          }
+        }
+      }
       return brokerRequest;
     } catch (Pql2CompilationException e) {
       throw e;
@@ -111,6 +150,63 @@ public class Pql2Compiler implements AbstractCompiler {
     }
   }
 
+  private boolean compare(BrokerRequest br1, BrokerRequest br2)
+      throws Exception {
+    //Having not yet supported
+    if (br1.getHavingFilterQuery() != null) {
+      return true;
+    }
+    boolean result = br1.equals(br2);
+    if (!result) {
+      StringBuilder sb = new StringBuilder();
+
+      if (br1.getFilterQuery() != null) {
+        if (!br1.getFilterQuery().equals(br2.getFilterQuery())) {
+          sb.append("br1.getFilterQuery() = ").append(br1.getFilterQuery()).append("\n")
+              .append("br2.getFilterQuery() = ").append(br2.getFilterQuery());
+          LOGGER.error("Filter did not match after conversion.{}", sb);
+          return false;
+        }
+
+        if (!br1.getFilterSubQueryMap().equals(br2.getFilterSubQueryMap())) {
+          sb.append("br1.getFilterSubQueryMap() = ").append(br1.getFilterSubQueryMap()).append("\n")
+              .append("br2.getFilterSubQueryMap() = ").append(br2.getFilterSubQueryMap());
+          LOGGER.error("FilterSubQueryMap did not match after conversion. {}", sb);
+          return false;
+        }
+      }
+      if (br1.getSelections() != null) {
+        if (!br1.getSelections().equals(br2.getSelections())) {
+          sb.append("br1.getSelections() = ").append(br1.getSelections()).append("\n").append("br2.getSelections() = ")
+              .append(br2.getSelections());
+          LOGGER.error("Selection did not match after conversion:{}", sb);
+          return false;
+        }
+      }
+      if (br1.getGroupBy() != null) {
+        if (!br1.getGroupBy().equals(br2.getGroupBy())) {
+          sb.append("br1.getGroupBy() = ").append(br1.getGroupBy()).append("\n").append("br2.getGroupBy() = ")
+              .append(br2.getGroupBy());
+          LOGGER.error("Group By did not match conversion:{}", sb);
+          return false;
+        }
+      }
+      if (br1.getAggregationsInfo() != null) {
+        List<AggregationInfo> aggregationsInfo = br1.getAggregationsInfo();
+        for (int i = 0; i < aggregationsInfo.size(); i++) {
+          AggregationInfo agg1 = br1.getAggregationsInfo().get(i);
+          AggregationInfo agg2 = br2.getAggregationsInfo().get(i);
+          if (!agg1.equals(agg2)) {
+            sb.append("br1.agg1 = ").append(agg1).append("\n").append("br2.agg2() = ").append(agg2);
+            LOGGER.error("AggregationInfo did not match after conversion: {}", sb);
+            return false;
+          }
+        }
+      }
+    }
+    return result;
+  }
+
   @Override
   public TransformExpressionTree compileToExpressionTree(String expression) {
     CharStream charStream = new ANTLRInputStream(expression);
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/AstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/AstNode.java
index f721c54..c8312c8 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/AstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/AstNode.java
@@ -20,6 +20,7 @@ package org.apache.pinot.pql.parsers.pql2.ast;
 
 import java.util.List;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.PinotQuery;
 
 
 /**
@@ -42,7 +43,11 @@ public interface AstNode {
 
   void updateBrokerRequest(BrokerRequest brokerRequest);
 
+  void updatePinotQuery(PinotQuery pinotQuery);
+
   void sendBrokerRequestUpdateToChildren(BrokerRequest brokerRequest);
 
+  void sendPinotQueryUpdateToChildren(PinotQuery pinotQuery);
+
   String toString(int indent);
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BaseAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BaseAstNode.java
index 1a8a703..196c8f3 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BaseAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BaseAstNode.java
@@ -21,6 +21,7 @@ package org.apache.pinot.pql.parsers.pql2.ast;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.PinotQuery;
 
 
 /**
@@ -72,6 +73,10 @@ public abstract class BaseAstNode implements AstNode {
   }
 
   @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+  }
+
+  @Override
   public void sendBrokerRequestUpdateToChildren(BrokerRequest brokerRequest) {
     if (hasChildren()) {
       for (AstNode child : _children) {
@@ -81,6 +86,15 @@ public abstract class BaseAstNode implements AstNode {
   }
 
   @Override
+  public void sendPinotQueryUpdateToChildren(PinotQuery pinotQuery) {
+    if (hasChildren()) {
+      for (AstNode child : _children) {
+        child.updatePinotQuery(pinotQuery);
+      }
+    }
+  }
+
+  @Override
   public String toString(int indent) {
     String str = "";
     for (int i = 0; i < indent; ++i) {
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BetweenPredicateAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BetweenPredicateAstNode.java
index 214ef30..3d989e9 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BetweenPredicateAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BetweenPredicateAstNode.java
@@ -19,9 +19,12 @@
 package org.apache.pinot.pql.parsers.pql2.ast;
 
 import java.util.Collections;
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.request.FilterOperator;
+import org.apache.pinot.common.request.Function;
 import org.apache.pinot.common.utils.request.FilterQueryTree;
 import org.apache.pinot.common.utils.request.HavingQueryTree;
+import org.apache.pinot.common.utils.request.RequestUtils;
 import org.apache.pinot.pql.parsers.Pql2CompilationException;
 
 
@@ -83,6 +86,31 @@ public class BetweenPredicateAstNode extends PredicateAstNode {
   }
 
   @Override
+  public Expression buildFilterExpression() {
+    if (_identifier == null) {
+      throw new Pql2CompilationException("Between predicate has no identifier");
+    }
+    if (getChildren().size() == 2) {
+      try {
+        LiteralAstNode left = (LiteralAstNode) getChildren().get(0);
+        LiteralAstNode right = (LiteralAstNode) getChildren().get(1);
+
+        final Expression betweenExpr = RequestUtils.createFunctionExpression(FilterKind.BETWEEN.name());
+        final Function rangeFuncCall = betweenExpr.getFunctionCall();
+        rangeFuncCall.addToOperands(RequestUtils.createIdentifierExpression(_identifier));
+        rangeFuncCall.addToOperands(RequestUtils.createLiteralExpression(left));
+        rangeFuncCall.addToOperands(RequestUtils.createLiteralExpression(right));
+        return betweenExpr;
+      } catch (ClassCastException e) {
+        throw new Pql2CompilationException(
+            "BETWEEN clause was expecting two literal AST nodes, got " + getChildren());
+      }
+    } else {
+      throw new Pql2CompilationException("BETWEEN clause does not have two children nodes");
+    }
+  }
+
+  @Override
   public HavingQueryTree buildHavingQueryTree() {
     if (_function == null) {
       throw new Pql2CompilationException("Between predicate has no function call specified");
@@ -96,8 +124,7 @@ public class BetweenPredicateAstNode extends PredicateAstNode {
             FilterOperator.RANGE, null);
       } catch (ClassCastException e) {
         throw new Pql2CompilationException(
-            "BETWEEN clause was expecting two literal AST nodes, got " + getChildren().get(0) + " and " + getChildren()
-                .get(1));
+            "BETWEEN clause was expecting two literal AST nodes, got " + getChildren());
       }
     } else {
       throw new Pql2CompilationException("BETWEEN clause does not have two children nodes");
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BooleanOperatorAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BooleanOperatorAstNode.java
index 74d41d0..de7b71a 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BooleanOperatorAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/BooleanOperatorAstNode.java
@@ -20,6 +20,7 @@ package org.apache.pinot.pql.parsers.pql2.ast;
 
 import java.util.List;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.PinotQuery;
 
 
 /**
@@ -67,11 +68,20 @@ public enum BooleanOperatorAstNode implements AstNode {
   }
 
   @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+  }
+
+  @Override
   public void sendBrokerRequestUpdateToChildren(BrokerRequest brokerRequest) {
     throw new AssertionError("Should not happen");
   }
 
   @Override
+  public void sendPinotQueryUpdateToChildren(PinotQuery pinotQuery) {
+    throw new AssertionError("Should not happen");
+  }
+
+  @Override
   public String toString(int indent) {
     String str = "";
     for (int i = 0; i < indent; ++i) {
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/ComparisonPredicateAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/ComparisonPredicateAstNode.java
index 4719d3b..e8771a8 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/ComparisonPredicateAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/ComparisonPredicateAstNode.java
@@ -19,9 +19,11 @@
 package org.apache.pinot.pql.parsers.pql2.ast;
 
 import java.util.Collections;
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.request.FilterOperator;
 import org.apache.pinot.common.utils.request.FilterQueryTree;
 import org.apache.pinot.common.utils.request.HavingQueryTree;
+import org.apache.pinot.common.utils.request.RequestUtils;
 import org.apache.pinot.pql.parsers.Pql2CompilationException;
 
 
@@ -156,6 +158,74 @@ public class ComparisonPredicateAstNode extends PredicateAstNode {
   }
 
   @Override
+  public Expression buildFilterExpression() {
+    if (_identifier == null) {
+      throw new Pql2CompilationException("Comparison predicate has no identifier");
+    }
+
+    if ("=".equals(_operand)) {
+      if (_identifier != null && _literal != null) {
+        Expression expr = RequestUtils.createFunctionExpression(FilterKind.EQUALS.name());
+        expr.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression(_identifier));
+        expr.getFunctionCall().addToOperands(RequestUtils.createLiteralExpression(_literal));
+        return expr;
+      } else {
+        throw new Pql2CompilationException("Comparison is not between a column and a constant");
+      }
+    } else if ("<>".equals(_operand) || "!=".equals(_operand)) {
+      if (_identifier != null && _literal != null) {
+        Expression expr = RequestUtils.createFunctionExpression(FilterKind.NOT_EQUALS.name());
+        expr.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression(_identifier));
+        expr.getFunctionCall().addToOperands(RequestUtils.createLiteralExpression(_literal));
+        return expr;
+      } else {
+        throw new Pql2CompilationException("Comparison is not between a column and a constant");
+      }
+    } else {
+      if (_identifier != null) {
+        boolean identifierIsOnLeft = true;
+        if (getChildren().get(0) instanceof LiteralAstNode) {
+          identifierIsOnLeft = false;
+        }
+        Expression expr = null;
+        if ("<".equals(_operand)) {
+          if (identifierIsOnLeft) {
+            expr = RequestUtils.createFunctionExpression(FilterKind.LESS_THAN.name());
+          } else {
+            expr = RequestUtils.createFunctionExpression(FilterKind.GREATER_THAN.name());
+          }
+        } else if ("<=".equals(_operand)) {
+          if (identifierIsOnLeft) {
+            expr = RequestUtils.createFunctionExpression(FilterKind.LESS_THAN_OR_EQUAL.name());
+          } else {
+            expr = RequestUtils.createFunctionExpression(FilterKind.GREATER_THAN_OR_EQUAL.name());
+          }
+        } else if (">".equals(_operand)) {
+          if (identifierIsOnLeft) {
+            expr = RequestUtils.createFunctionExpression(FilterKind.GREATER_THAN.name());
+          } else {
+            expr = RequestUtils.createFunctionExpression(FilterKind.LESS_THAN.name());
+          }
+        } else if (">=".equals(_operand)) {
+          if (identifierIsOnLeft) {
+            expr = RequestUtils.createFunctionExpression(FilterKind.GREATER_THAN_OR_EQUAL.name());
+          } else {
+            expr = RequestUtils.createFunctionExpression(FilterKind.LESS_THAN_OR_EQUAL.name());
+          }
+        }
+        if (expr == null) {
+          throw new Pql2CompilationException("The comparison operator is not valid/is not supported for HAVING query");
+        }
+        expr.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression(_identifier));
+        expr.getFunctionCall().addToOperands(RequestUtils.createLiteralExpression(_literal));
+        return expr;
+      } else {
+        throw new Pql2CompilationException("One column is needed for comparison.");
+      }
+    }
+  }
+
+  @Override
   public HavingQueryTree buildHavingQueryTree() {
     if (_function == null) {
       throw new Pql2CompilationException("Comparison predicate has no function");
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionsAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FilterKind.java
similarity index 67%
copy from pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionsAstNode.java
copy to pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FilterKind.java
index 5f2cb73..baca493 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionsAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/FilterKind.java
@@ -18,20 +18,17 @@
  */
 package org.apache.pinot.pql.parsers.pql2.ast;
 
-import java.util.HashMap;
-import org.apache.pinot.common.request.BrokerRequest;
-
-
-/**
- * AST node for query options.
- */
-public class OptionsAstNode extends BaseAstNode {
-  @Override
-  public void updateBrokerRequest(BrokerRequest brokerRequest) {
-    if (brokerRequest.getQueryOptions() == null) {
-      brokerRequest.setQueryOptions(new HashMap<>());
-    }
-
-    sendBrokerRequestUpdateToChildren(brokerRequest);
-  }
+public enum FilterKind {
+  AND,
+  OR,
+  EQUALS,
+  NOT_EQUALS,
+  GREATER_THAN,
+  GREATER_THAN_OR_EQUAL,
+  LESS_THAN,
+  LESS_THAN_OR_EQUAL,
+  BETWEEN,
+  IN,
+  NOT_IN,
+  REGEXP_LIKE
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/GroupByAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/GroupByAstNode.java
index b2aa973..d250da4 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/GroupByAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/GroupByAstNode.java
@@ -18,9 +18,14 @@
  */
 package org.apache.pinot.pql.parsers.pql2.ast;
 
+import java.util.ArrayList;
+import java.util.List;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.request.GroupBy;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.common.request.transform.TransformExpressionTree;
+import org.apache.pinot.common.utils.request.RequestUtils;
 
 
 /**
@@ -36,4 +41,13 @@ public class GroupByAstNode extends BaseAstNode {
     }
     brokerRequest.setGroupBy(groupBy);
   }
+
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    List<Expression> groupBy = new ArrayList<>();
+    for (AstNode child : getChildren()) {
+      groupBy.add(RequestUtils.getExpression(child));
+    }
+    pinotQuery.setGroupByList(groupBy);
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/HavingAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/HavingAstNode.java
index 573caf0..c8491f8 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/HavingAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/HavingAstNode.java
@@ -19,6 +19,7 @@
 package org.apache.pinot.pql.parsers.pql2.ast;
 
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.common.utils.request.RequestUtils;
 
 
@@ -31,4 +32,8 @@ public class HavingAstNode extends BaseAstNode {
     PredicateAstNode predicateAstNode = (PredicateAstNode) getChildren().get(0);
     RequestUtils.generateFilterFromTree(predicateAstNode.buildHavingQueryTree(), brokerRequest);
   }
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    // Skip HavingAstNode for now.
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/InPredicateAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/InPredicateAstNode.java
index 6be33f3..cbdf0db 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/InPredicateAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/InPredicateAstNode.java
@@ -20,13 +20,15 @@ package org.apache.pinot.pql.parsers.pql2.ast;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Set;
 import java.util.TreeSet;
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.request.FilterOperator;
 import org.apache.pinot.common.utils.StringUtil;
 import org.apache.pinot.common.utils.request.FilterQueryTree;
 import org.apache.pinot.common.utils.request.HavingQueryTree;
+import org.apache.pinot.common.utils.request.RequestUtils;
 import org.apache.pinot.pql.parsers.Pql2CompilationException;
 
 
@@ -92,7 +94,7 @@ public class InPredicateAstNode extends PredicateAstNode {
       throw new Pql2CompilationException("IN predicate has no identifier");
     }
 
-    Set<String> values = new HashSet<>();
+    Set<String> values = new LinkedHashSet<>();
 
     for (AstNode astNode : getChildren()) {
       if (astNode instanceof LiteralAstNode) {
@@ -112,6 +114,35 @@ public class InPredicateAstNode extends PredicateAstNode {
   }
 
   @Override
+  public Expression buildFilterExpression() {
+    if (_identifier == null) {
+      throw new Pql2CompilationException("IN predicate has no identifier");
+    }
+    FilterKind filterOperator;
+    if (_isNotInClause) {
+      filterOperator = FilterKind.NOT_IN;
+    } else {
+      filterOperator = FilterKind.IN;
+    }
+    Expression expr = RequestUtils.createFunctionExpression(filterOperator.name());
+    expr.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression(_identifier));
+
+    Set<String> values = new LinkedHashSet<>();
+
+    for (AstNode astNode : getChildren()) {
+      if (astNode instanceof LiteralAstNode) {
+        LiteralAstNode node = (LiteralAstNode) astNode;
+        if(!values.contains(node.getValueAsString())) {
+          values.add(node.getValueAsString());
+          Expression literalExpression = RequestUtils.createLiteralExpression(node);
+          expr.getFunctionCall().addToOperands(literalExpression);
+        }
+      }
+    }
+    return expr;
+  }
+
+  @Override
   public HavingQueryTree buildHavingQueryTree() {
 
     if (_function == null) {
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionAstNode.java
index 11b50f8..a28eba7 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionAstNode.java
@@ -19,6 +19,7 @@
 package org.apache.pinot.pql.parsers.pql2.ast;
 
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.pql.parsers.Pql2CompilationException;
 
 
@@ -54,4 +55,33 @@ public class OptionAstNode extends BaseAstNode {
 
     brokerRequest.getQueryOptions().put(left, right);
   }
+
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    if (getChildren().size() != 2) {
+      throw new Pql2CompilationException("Expected exactly two children for OptionAstNode");
+    }
+
+    String left;
+    AstNode leftNode = getChildren().get(0);
+
+    String right;
+    AstNode rightNode = getChildren().get(1);
+
+    if (leftNode instanceof IdentifierAstNode) {
+      left = ((IdentifierAstNode) leftNode).getExpression();
+    } else {
+      throw new Pql2CompilationException("Expected left child node of OptionAstNode to be an identifier");
+    }
+
+    if (rightNode instanceof IdentifierAstNode) {
+      right = ((IdentifierAstNode) rightNode).getExpression();
+    } else if (rightNode instanceof LiteralAstNode) {
+      right = ((LiteralAstNode) rightNode).getValueAsString();
+    } else {
+      throw new Pql2CompilationException("Right node of OptionAstNode is neither an identifier nor a literal");
+    }
+
+    pinotQuery.getQueryOptions().put(left, right);
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionsAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionsAstNode.java
index 5f2cb73..a9d69e6 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionsAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OptionsAstNode.java
@@ -20,6 +20,7 @@ package org.apache.pinot.pql.parsers.pql2.ast;
 
 import java.util.HashMap;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.PinotQuery;
 
 
 /**
@@ -31,7 +32,14 @@ public class OptionsAstNode extends BaseAstNode {
     if (brokerRequest.getQueryOptions() == null) {
       brokerRequest.setQueryOptions(new HashMap<>());
     }
-
     sendBrokerRequestUpdateToChildren(brokerRequest);
   }
+
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    if (pinotQuery.getQueryOptions() == null) {
+      pinotQuery.setQueryOptions(new HashMap<>());
+    }
+    sendPinotQueryUpdateToChildren(pinotQuery);
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OrderByAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OrderByAstNode.java
index 56a8c45..ee0677a 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OrderByAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OrderByAstNode.java
@@ -19,8 +19,12 @@
 package org.apache.pinot.pql.parsers.pql2.ast;
 
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.Function;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.common.request.Selection;
 import org.apache.pinot.common.request.SelectionSort;
+import org.apache.pinot.common.utils.request.RequestUtils;
 import org.apache.pinot.pql.parsers.Pql2CompilationException;
 
 
@@ -44,4 +48,24 @@ public class OrderByAstNode extends BaseAstNode {
       }
     }
   }
+
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    for (AstNode astNode : getChildren()) {
+      if (astNode instanceof OrderByExpressionAstNode) {
+        OrderByExpressionAstNode node = (OrderByExpressionAstNode) astNode;
+        String ordering = "desc";
+        if ("asc".equalsIgnoreCase(node.getOrdering())) {
+          ordering = "asc";
+        }
+        Expression orderByExpression = RequestUtils.createFunctionExpression(ordering);
+        Function orderByFunc = orderByExpression.getFunctionCall();
+        Expression colExpr = RequestUtils.createIdentifierExpression(node.getColumn());
+        orderByFunc.addToOperands(colExpr);
+        pinotQuery.addToOrderByList(orderByExpression);
+      } else {
+        throw new Pql2CompilationException("Child node of ORDER BY node is not an expression node");
+      }
+    }
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OutputColumnAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OutputColumnAstNode.java
index 3c08387..3798fbd 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OutputColumnAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OutputColumnAstNode.java
@@ -19,7 +19,10 @@
 package org.apache.pinot.pql.parsers.pql2.ast;
 
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.common.request.Selection;
+import org.apache.pinot.common.utils.request.RequestUtils;
 import org.apache.pinot.pql.parsers.Pql2CompilationException;
 
 
@@ -48,4 +51,28 @@ public class OutputColumnAstNode extends BaseAstNode {
       }
     }
   }
+
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    for (AstNode astNode : getChildren()) {
+      // If the column is a function call, it must be an aggregation function
+      if (astNode instanceof FunctionCallAstNode) {
+        FunctionCallAstNode node = (FunctionCallAstNode) astNode;
+        Expression functionExpr;
+        if (node.getName().equalsIgnoreCase("count")) {
+          // COUNT aggregation function always works on '*'
+          functionExpr = RequestUtils.createFunctionExpression(node.getName());
+          functionExpr.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression("*"));
+        } else {
+          functionExpr = RequestUtils.getExpression(astNode);
+        }
+        pinotQuery.addToSelectList(functionExpr);
+      } else if (astNode instanceof IdentifierAstNode) {
+        IdentifierAstNode node = (IdentifierAstNode) astNode;
+        pinotQuery.addToSelectList(RequestUtils.createIdentifierExpression(node.getName()));
+      } else {
+        throw new Pql2CompilationException("Output column is neither a function nor an identifier");
+      }
+    }
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OutputColumnListAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OutputColumnListAstNode.java
index a9d0a8b..bc2c01e 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OutputColumnListAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/OutputColumnListAstNode.java
@@ -19,6 +19,7 @@
 package org.apache.pinot.pql.parsers.pql2.ast;
 
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.PinotQuery;
 
 
 /**
@@ -44,4 +45,9 @@ public class OutputColumnListAstNode extends BaseAstNode {
   public void updateBrokerRequest(BrokerRequest brokerRequest) {
     sendBrokerRequestUpdateToChildren(brokerRequest);
   }
+
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    sendPinotQueryUpdateToChildren(pinotQuery);
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateAstNode.java
index d501467..de9d882 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateAstNode.java
@@ -18,6 +18,7 @@
  */
 package org.apache.pinot.pql.parsers.pql2.ast;
 
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.utils.request.FilterQueryTree;
 import org.apache.pinot.common.utils.request.HavingQueryTree;
 
@@ -33,11 +34,17 @@ public abstract class PredicateAstNode extends BaseAstNode {
    * Create the query tree for the where clause
    *
    * @return
-   *
    */
   public abstract FilterQueryTree buildFilterQueryTree();
 
   /**
+   * Create the query expression tree for the where clause
+   *
+   * @return
+   */
+  public abstract Expression buildFilterExpression();
+
+  /**
    * Create the query tree for the having clause
    * It is different than FilterQuery because here we deal with function call comparison with literals
    * @return
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateListAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateListAstNode.java
index 3225cd3..951ec74 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateListAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateListAstNode.java
@@ -20,9 +20,11 @@ package org.apache.pinot.pql.parsers.pql2.ast;
 
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.request.FilterOperator;
 import org.apache.pinot.common.utils.request.FilterQueryTree;
 import org.apache.pinot.common.utils.request.HavingQueryTree;
+import org.apache.pinot.common.utils.request.RequestUtils;
 
 
 /**
@@ -68,7 +70,6 @@ public class PredicateListAstNode extends PredicateAstNode {
             filterQueryAndPredicates.add(predicate.buildFilterQueryTree());
             filterQueryOrPredicates.add(buildFilterPredicate(filterQueryAndPredicates, FilterOperator.AND));
             filterQueryAndPredicates = new ArrayList<>();
-            ;
           } else {
             filterQueryOrPredicates.add(predicate.buildFilterQueryTree());
           }
@@ -120,6 +121,70 @@ public class PredicateListAstNode extends PredicateAstNode {
   }
 
   @Override
+  public Expression buildFilterExpression() {
+
+    List<Expression> filterQueryOrExpressions = new ArrayList<>();
+    List<Expression> filterQueryAndExpressions = new ArrayList<>();
+
+    int childrenCount = getChildren().size();
+    if (childrenCount == 1) {
+      return ((PredicateAstNode) getChildren().get(0)).buildFilterExpression();
+    }
+
+    for (int i = 0; i < childrenCount; i += 2) {
+      PredicateAstNode predicate = (PredicateAstNode) getChildren().get(i);
+      BooleanOperatorAstNode nextOperator = null;
+
+      if (i + 1 < childrenCount) {
+        nextOperator = (BooleanOperatorAstNode) getChildren().get(i + 1);
+      }
+      // 3 cases for the next operator:
+      // - No next operator: Add the predicate to the AND predicates or to the parent OR predicate
+      // - AND: Add the predicate to the AND predicates, creating it if necessary
+      // - OR:
+      //   1. Add the predicate to the AND predicates if it exists, then add it to the parent OR predicate
+      //   2. If there is no current AND predicate list, add the predicate directly
+      //   3. Clear the current AND predicates list
+      // Is it the last predicate?
+      if (nextOperator == null) {
+        if (!filterQueryAndExpressions.isEmpty()) {
+          filterQueryAndExpressions.add(predicate.buildFilterExpression());
+          if (!filterQueryOrExpressions.isEmpty()) {
+            filterQueryOrExpressions.add(buildFilterExpression(FilterKind.AND, filterQueryAndExpressions));
+          }
+        } else {
+          // Previous predicate was OR, therefore add the predicate directly
+          filterQueryOrExpressions.add(predicate.buildFilterExpression());
+        }
+      } else if (nextOperator == BooleanOperatorAstNode.AND) {
+        filterQueryAndExpressions.add(predicate.buildFilterExpression());
+      } else {
+        if (!filterQueryAndExpressions.isEmpty()) {
+          filterQueryAndExpressions.add(predicate.buildFilterExpression());
+          filterQueryOrExpressions.add(buildFilterExpression(FilterKind.AND, filterQueryAndExpressions));
+          filterQueryAndExpressions = new ArrayList<>();
+        } else {
+          filterQueryOrExpressions.add(predicate.buildFilterExpression());
+        }
+      }
+    }
+
+    if (!filterQueryOrExpressions.isEmpty()) {
+      return buildFilterExpression(FilterKind.OR, filterQueryOrExpressions);
+    } else {
+      return buildFilterExpression(FilterKind.AND, filterQueryAndExpressions);
+    }
+  }
+
+  public Expression buildFilterExpression(FilterKind operator, List<Expression> children) {
+    final Expression expression = RequestUtils.createFunctionExpression(operator.name());
+    for (Expression child : children) {
+      expression.getFunctionCall().addToOperands(child);
+    }
+    return expression;
+  }
+
+  @Override
   public HavingQueryTree buildHavingQueryTree() {
     List<HavingQueryTree> orPredicates = new ArrayList<>();
     List<HavingQueryTree> andPredicates = new ArrayList<>();
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateParenthesisGroupAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateParenthesisGroupAstNode.java
index ad31cb9..88f4c2e 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateParenthesisGroupAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/PredicateParenthesisGroupAstNode.java
@@ -18,6 +18,7 @@
  */
 package org.apache.pinot.pql.parsers.pql2.ast;
 
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.utils.request.FilterQueryTree;
 import org.apache.pinot.common.utils.request.HavingQueryTree;
 
@@ -32,6 +33,11 @@ public class PredicateParenthesisGroupAstNode extends PredicateAstNode {
   }
 
   @Override
+  public Expression buildFilterExpression() {
+    return ((PredicateAstNode) getChildren().get(0)).buildFilterExpression();
+  }
+
+  @Override
   public HavingQueryTree buildHavingQueryTree() {
     return ((PredicateAstNode) getChildren().get(0)).buildHavingQueryTree();
   }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/RegexpLikePredicateAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/RegexpLikePredicateAstNode.java
index 6917da1..3375312 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/RegexpLikePredicateAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/RegexpLikePredicateAstNode.java
@@ -22,10 +22,12 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.request.FilterOperator;
 import org.apache.pinot.common.utils.StringUtil;
 import org.apache.pinot.common.utils.request.FilterQueryTree;
 import org.apache.pinot.common.utils.request.HavingQueryTree;
+import org.apache.pinot.common.utils.request.RequestUtils;
 import org.apache.pinot.pql.parsers.Pql2CompilationException;
 
 
@@ -75,6 +77,22 @@ public class RegexpLikePredicateAstNode extends PredicateAstNode {
   }
 
   @Override
+  public Expression buildFilterExpression() {
+    if (_identifier == null) {
+      throw new Pql2CompilationException("REGEXP_LIKE predicate has no identifier");
+    }
+    Expression expression = RequestUtils.createFunctionExpression(FilterKind.REGEXP_LIKE.name());
+    expression.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression(_identifier));
+    if (getChildren().size() > 1) {
+      throw new Pql2CompilationException("Matching more than one regex is NOT supported currently");
+    }
+    for (AstNode astNode : getChildren()) {
+      expression.getFunctionCall().addToOperands(RequestUtils.getExpression(astNode));
+    }
+    return expression;
+  }
+
+  @Override
   public HavingQueryTree buildHavingQueryTree() {
     throw new Pql2CompilationException("REGEXP_LIKE predicate is not supported in HAVING clause.");
   }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/SelectAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/SelectAstNode.java
index c03cd7b..4af8e51 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/SelectAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/SelectAstNode.java
@@ -19,7 +19,9 @@
 package org.apache.pinot.pql.parsers.pql2.ast;
 
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.DataSource;
 import org.apache.pinot.common.request.GroupBy;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.common.request.QuerySource;
 import org.apache.pinot.common.request.Selection;
 import org.apache.pinot.pql.parsers.Pql2CompilationException;
@@ -122,6 +124,9 @@ public class SelectAstNode extends BaseAstNode {
     if (selections != null) {
       if (_recordLimit != -1) {
         selections.setSize(_recordLimit);
+      } else {
+        // Pinot quirk: default to LIMIT 10
+        selections.setSize(10);
       }
       if (_offset != -1) {
         selections.setOffset(_offset);
@@ -144,4 +149,30 @@ public class SelectAstNode extends BaseAstNode {
       brokerRequest.setSelections(null);
     }
   }
+
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    // Set data source
+    DataSource dataSource = new DataSource();
+    dataSource.setTableName(_resourceName);
+    pinotQuery.setDataSource(dataSource);
+    sendPinotQueryUpdateToChildren(pinotQuery);
+    if (_recordLimit != -1) {
+      pinotQuery.setLimit(_recordLimit);
+    } else {
+      // Pinot quirk: default to top 10
+      pinotQuery.setLimit(10);
+    }
+    if (_offset != -1) {
+      pinotQuery.setOffset(_offset);
+    }
+    if (pinotQuery.getGroupByListSize() > 0) {
+      if (_topN != -1) {
+        pinotQuery.setLimit(_topN);
+      } else {
+        // Pinot quirk: default to top 10
+        pinotQuery.setLimit(10);
+      }
+    }
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/StarColumnListAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/StarColumnListAstNode.java
index 144f636..7ea94f5 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/StarColumnListAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/StarColumnListAstNode.java
@@ -21,7 +21,10 @@ package org.apache.pinot.pql.parsers.pql2.ast;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.common.request.Selection;
+import org.apache.pinot.common.utils.request.RequestUtils;
 
 
 /**
@@ -36,4 +39,10 @@ public class StarColumnListAstNode extends BaseAstNode {
     selection.setSelectionColumns(modifiableList);
     brokerRequest.setSelections(selection);
   }
+
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    Expression starExpr = RequestUtils.createIdentifierExpression("*");
+    pinotQuery.addToSelectList(starExpr);
+  }
 }
diff --git a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/WhereAstNode.java b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/WhereAstNode.java
index e351ef5..6b35ec4 100644
--- a/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/WhereAstNode.java
+++ b/pinot-common/src/main/java/org/apache/pinot/pql/parsers/pql2/ast/WhereAstNode.java
@@ -19,6 +19,7 @@
 package org.apache.pinot.pql.parsers.pql2.ast;
 
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.common.utils.request.RequestUtils;
 
 
@@ -31,4 +32,10 @@ public class WhereAstNode extends BaseAstNode {
     PredicateAstNode predicateAstNode = (PredicateAstNode) getChildren().get(0);
     RequestUtils.generateFilterFromTree(predicateAstNode.buildFilterQueryTree(), brokerRequest);
   }
+
+  @Override
+  public void updatePinotQuery(PinotQuery pinotQuery) {
+    PredicateAstNode predicateAstNode = (PredicateAstNode) getChildren().get(0);
+    pinotQuery.setFilterExpression(predicateAstNode.buildFilterExpression());
+  }
 }
diff --git a/pinot-common/src/test/java/org/apache/pinot/pql/parsers/Pql2CompilerTest.java b/pinot-common/src/test/java/org/apache/pinot/pql/parsers/Pql2CompilerTest.java
index 8d57811..694b385 100644
--- a/pinot-common/src/test/java/org/apache/pinot/pql/parsers/Pql2CompilerTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/pql/parsers/Pql2CompilerTest.java
@@ -18,14 +18,22 @@
  */
 package org.apache.pinot.pql.parsers;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.Collections;
 import java.util.List;
 import org.apache.pinot.common.request.AggregationInfo;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.request.FilterOperator;
+import org.apache.pinot.common.request.Function;
 import org.apache.pinot.common.request.GroupBy;
 import org.apache.pinot.common.request.transform.TransformExpressionTree;
+import org.apache.pinot.pql.parsers.pql2.ast.FilterKind;
 import org.apache.pinot.pql.parsers.pql2.ast.TopAstNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
@@ -35,21 +43,92 @@ import org.testng.annotations.Test;
  */
 public class Pql2CompilerTest {
   private static final Pql2Compiler COMPILER = new Pql2Compiler();
+  private static final Logger LOGGER = LoggerFactory.getLogger(Pql2Compiler.class);
 
   @Test
   public void testQuotedStrings() {
     BrokerRequest brokerRequest =
         COMPILER.compileToBrokerRequest("select * from vegetables where origin = 'Martha''s Vineyard'");
     Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "Martha's Vineyard");
+    // Test PinotQuery
+    Assert.assertEquals(
+        brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral()
+            .getStringValue(), "Martha's Vineyard");
 
     brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where origin = 'Martha\"\"s Vineyard'");
     Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "Martha\"\"s Vineyard");
+    // Test PinotQuery
+    Assert.assertEquals(
+        brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral()
+            .getStringValue(), "Martha\"\"s Vineyard");
 
     brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where origin = \"Martha\"\"s Vineyard\"");
     Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "Martha\"s Vineyard");
+    // Test PinotQuery
+    Assert.assertEquals(
+        brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral()
+            .getStringValue(), "Martha\"s Vineyard");
 
     brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where origin = \"Martha''s Vineyard\"");
     Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "Martha''s Vineyard");
+    // Test PinotQuery
+    Assert.assertEquals(
+        brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperands().get(1).getLiteral()
+            .getStringValue(), "Martha''s Vineyard");
+  }
+
+  @Test
+  public void testFilterCaluses() {
+    BrokerRequest brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where a > 1");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getColumn(), "a");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.RANGE);
+    Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "(1\t\t*)");
+    // Test PinotQuery
+    Function func = brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall();
+    Assert.assertEquals(func.getOperator(), FilterKind.GREATER_THAN.name());
+    Assert.assertEquals(func.getOperands().get(0).getIdentifier().getName(), "a");
+    Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 1);
+
+    brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where b < 100");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getColumn(), "b");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.RANGE);
+    Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "(*\t\t100)");
+    // Test PinotQuery
+    func = brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall();
+    Assert.assertEquals(func.getOperator(), FilterKind.LESS_THAN.name());
+    Assert.assertEquals(func.getOperands().get(0).getIdentifier().getName(), "b");
+    Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 100);
+
+    brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where c >= 10");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getColumn(), "c");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.RANGE);
+    Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "[10\t\t*)");
+    // Test PinotQuery
+    func = brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall();
+    Assert.assertEquals(func.getOperator(), FilterKind.GREATER_THAN_OR_EQUAL.name());
+    Assert.assertEquals(func.getOperands().get(0).getIdentifier().getName(), "c");
+    Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 10);
+
+    brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where d <= 50");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getColumn(), "d");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.RANGE);
+    Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "(*\t\t50]");
+    // Test PinotQuery
+    func = brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall();
+    Assert.assertEquals(func.getOperator(), FilterKind.LESS_THAN_OR_EQUAL.name());
+    Assert.assertEquals(func.getOperands().get(0).getIdentifier().getName(), "d");
+    Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 50);
+
+    brokerRequest = COMPILER.compileToBrokerRequest("select * from vegetables where e BETWEEN 70 AND 80");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getColumn(), "e");
+    Assert.assertEquals(brokerRequest.getFilterQuery().getOperator(), FilterOperator.RANGE);
+    Assert.assertEquals(brokerRequest.getFilterQuery().getValue().get(0), "[70\t\t80]");
+    // Test PinotQuery
+    func = brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall();
+    Assert.assertEquals(func.getOperator(), FilterKind.BETWEEN.name());
+    Assert.assertEquals(func.getOperands().get(0).getIdentifier().getName(), "e");
+    Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(), 70);
+    Assert.assertEquals(func.getOperands().get(2).getLiteral().getLongValue(), 80);
   }
 
   @Test
@@ -64,7 +143,7 @@ public class Pql2CompilerTest {
 
   @Test
   public void testTopZero() {
-    testTopZeroFor("select count(*) from someTable where c = 5 group by X top 0", TopAstNode.DEFAULT_TOP_N, false);
+    testTopZeroFor("select COUNT(*) from someTable where c = 5 group by X top 0", TopAstNode.DEFAULT_TOP_N, false);
     testTopZeroFor("select count(*) from someTable where c = 5 group by X top 1", 1, false);
     testTopZeroFor("select count(*) from someTable where c = 5 group by X top -1", TopAstNode.DEFAULT_TOP_N, true);
   }
@@ -94,6 +173,11 @@ public class Pql2CompilerTest {
     GroupBy groupBy = req.getGroupBy();
     Assert.assertTrue(groupBy.isSetTopN());
     Assert.assertEquals(expectedTopN, groupBy.getTopN());
+
+    // Test PinotQuery
+    Assert.assertTrue(req.getPinotQuery().isSetGroupByList());
+    Assert.assertTrue(req.getPinotQuery().isSetLimit());
+    Assert.assertEquals(expectedTopN, req.getPinotQuery().getLimit());
   }
 
   @Test
@@ -170,12 +254,19 @@ public class Pql2CompilerTest {
         COMPILER.compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts'");
     Assert.assertEquals(brokerRequest.getQueryOptionsSize(), 0);
     Assert.assertNull(brokerRequest.getQueryOptions());
+    // Test PinotQuery
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptionsSize(), 0);
+    Assert.assertNull(brokerRequest.getPinotQuery().getQueryOptions());
 
     brokerRequest = COMPILER
         .compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts' OPTION (delicious=yes)");
     Assert.assertEquals(brokerRequest.getQueryOptionsSize(), 1);
     Assert.assertTrue(brokerRequest.getQueryOptions().containsKey("delicious"));
     Assert.assertEquals(brokerRequest.getQueryOptions().get("delicious"), "yes");
+    // Test PinotQuery
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptionsSize(), 1);
+    Assert.assertTrue(brokerRequest.getPinotQuery().getQueryOptions().containsKey("delicious"));
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptions().get("delicious"), "yes");
 
     brokerRequest = COMPILER.compileToBrokerRequest(
         "select * from vegetables where name != 'Brussels sprouts' OPTION (delicious=yes, foo=1234, bar='potato')");
@@ -184,6 +275,12 @@ public class Pql2CompilerTest {
     Assert.assertEquals(brokerRequest.getQueryOptions().get("delicious"), "yes");
     Assert.assertEquals(brokerRequest.getQueryOptions().get("foo"), "1234");
     Assert.assertEquals(brokerRequest.getQueryOptions().get("bar"), "potato");
+    // Test PinotQuery
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptionsSize(), 3);
+    Assert.assertTrue(brokerRequest.getPinotQuery().getQueryOptions().containsKey("delicious"));
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptions().get("delicious"), "yes");
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptions().get("foo"), "1234");
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptions().get("bar"), "potato");
 
     brokerRequest = COMPILER.compileToBrokerRequest(
         "select * from vegetables where name != 'Brussels sprouts' OPTION (delicious=yes) option(foo=1234) option(bar='potato')");
@@ -192,6 +289,12 @@ public class Pql2CompilerTest {
     Assert.assertEquals(brokerRequest.getQueryOptions().get("delicious"), "yes");
     Assert.assertEquals(brokerRequest.getQueryOptions().get("foo"), "1234");
     Assert.assertEquals(brokerRequest.getQueryOptions().get("bar"), "potato");
+    // Test PinotQuery
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptionsSize(), 3);
+    Assert.assertTrue(brokerRequest.getPinotQuery().getQueryOptions().containsKey("delicious"));
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptions().get("delicious"), "yes");
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptions().get("foo"), "1234");
+    Assert.assertEquals(brokerRequest.getPinotQuery().getQueryOptions().get("bar"), "potato");
   }
 
   @Test
@@ -209,6 +312,13 @@ public class Pql2CompilerTest {
         Collections.singletonList("attributes.address_city"));
     Assert.assertEquals(brokerRequest.getHavingFilterQuery().getAggregationInfo().getAggregationParams().get("column"),
         "attributes.age");
+
+    // Test PinotQuery
+    Assert.assertEquals(
+        brokerRequest.getPinotQuery().getSelectList().get(0).getFunctionCall().getOperands().get(0).getIdentifier()
+            .getName(), "attributes.age");
+    Assert.assertEquals(brokerRequest.getPinotQuery().getGroupByList().get(0).getIdentifier().getName(),
+        "attributes.address_city");
   }
 
   @Test
@@ -228,6 +338,18 @@ public class Pql2CompilerTest {
     Assert.assertEquals(expressions.get(0), "foo");
     Assert.assertEquals(expressions.get(1), "bar");
 
+    // Test PinotQuery
+    List<Expression> selectFunctionList = brokerRequest.getPinotQuery().getSelectList();
+    Assert.assertEquals(selectFunctionList.size(), 2);
+    Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getLiteral().getStringValue(),
+        "foo");
+    Assert.assertEquals(selectFunctionList.get(1).getFunctionCall().getOperands().get(0).getLiteral().getStringValue(),
+        "bar");
+    List<Expression> groupbyList = brokerRequest.getPinotQuery().getGroupByList();
+    Assert.assertEquals(groupbyList.size(), 2);
+    Assert.assertEquals(groupbyList.get(0).getLiteral().getStringValue(), "foo");
+    Assert.assertEquals(groupbyList.get(1).getLiteral().getStringValue(), "bar");
+
     // For UDF, string literal won't be treated as column but as LITERAL
     brokerRequest =
         COMPILER.compileToBrokerRequest("SELECT SUM(ADD(foo, 'bar')) FROM table GROUP BY SUB(\"foo\", bar)");
@@ -237,5 +359,65 @@ public class Pql2CompilerTest {
     expressions = brokerRequest.getGroupBy().getExpressions();
     Assert.assertEquals(expressions.size(), 1);
     Assert.assertEquals(expressions.get(0), "sub('foo',bar)");
+
+    // Test PinotQuery
+    selectFunctionList = brokerRequest.getPinotQuery().getSelectList();
+    Assert.assertEquals(selectFunctionList.size(), 1);
+    Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperator(), "SUM");
+    Assert.assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().size(), 1);
+
+    Assert
+        .assertEquals(selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperator(),
+            "ADD");
+    Assert.assertEquals(
+        selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().size(), 2);
+    Assert.assertEquals(
+        selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(0)
+            .getIdentifier().getName(), "foo");
+    Assert.assertEquals(
+        selectFunctionList.get(0).getFunctionCall().getOperands().get(0).getFunctionCall().getOperands().get(1)
+            .getLiteral().getStringValue(), "bar");
+    groupbyList = brokerRequest.getPinotQuery().getGroupByList();
+    Assert.assertEquals(groupbyList.size(), 1);
+    Assert.assertEquals(groupbyList.get(0).getFunctionCall().getOperator(), "SUB");
+    Assert.assertEquals(groupbyList.get(0).getFunctionCall().getOperands().size(), 2);
+    Assert.assertEquals(groupbyList.get(0).getFunctionCall().getOperands().get(0).getLiteral().getStringValue(), "foo");
+    Assert.assertEquals(groupbyList.get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(), "bar");
+  }
+
+  @Test
+  public void testConverter()
+      throws IOException {
+    Pql2Compiler.ENABLE_PINOT_QUERY = true;
+    Pql2Compiler.VALIDATE_CONVERTER = true;
+    Pql2Compiler.FAIL_ON_CONVERSION_ERROR = true;
+    COMPILER.compileToBrokerRequest("Select * from T where a IN (1,2,2,3,4)");
+
+    COMPILER.compileToBrokerRequest("SELECT MIN(div(DaysSinceEpoch,2)) FROM mytable");
+    COMPILER.compileToBrokerRequest(
+        "SELECT SUM(DepDelayMinutes), SUM(ArrDel15), SUM(DepDelay), SUM(DepDel15) FROM myStarTable WHERE Carrier IN ('UA', 'WN', 'FL', 'F9') AND Carrier NOT IN ('EV', 'AS', 'FL') AND DayofMonth > 5 AND DayofMonth <= 17 AND Diverted > 0 AND OriginCityName > 'Detroit, MI' GROUP BY CRSDepTime");
+    COMPILER.compileToBrokerRequest("Select * from T where a > 1 and a < 10");
+    COMPILER.compileToBrokerRequest("Select * from T where a between 1 and 10");
+
+    BrokerRequest brokerRequest =
+        COMPILER.compileToBrokerRequest("select * from vegetables where name != 'Brussels sprouts'");
+    Assert.assertEquals(brokerRequest.getPinotQuery().getFilterExpression().getFunctionCall().getOperator(),
+        FilterKind.NOT_EQUALS.name());
+    final BufferedReader br = new BufferedReader(
+        new InputStreamReader(Pql2CompilerTest.class.getClassLoader().getResourceAsStream("pql_queries.list")));
+    String pql;
+    int seqId = 0;
+    while ((pql = br.readLine()) != null) {
+      try {
+        LOGGER.info("Trying to compile PQL Id - {}, PQL: {}", seqId++, pql);
+        COMPILER.compileToBrokerRequest(pql);
+      } catch (Exception e) {
+        LOGGER.error("Failed to compile pql {} to BrokerRequest.", pql, e);
+        throw e;
+      }
+    }
+    Pql2Compiler.ENABLE_PINOT_QUERY = true;
+    Pql2Compiler.VALIDATE_CONVERTER = true;
+    Pql2Compiler.FAIL_ON_CONVERSION_ERROR = true;
   }
 }
diff --git a/pinot-common/src/test/java/org/apache/pinot/request/BrokerRequestSerializationTest.java b/pinot-common/src/test/java/org/apache/pinot/request/BrokerRequestSerializationTest.java
index f8864fe..6afbcd2 100644
--- a/pinot-common/src/test/java/org/apache/pinot/request/BrokerRequestSerializationTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/request/BrokerRequestSerializationTest.java
@@ -22,14 +22,19 @@ import java.util.ArrayList;
 import java.util.List;
 import org.apache.pinot.common.request.AggregationInfo;
 import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.DataSource;
+import org.apache.pinot.common.request.Expression;
 import org.apache.pinot.common.request.FilterOperator;
 import org.apache.pinot.common.request.FilterQuery;
 import org.apache.pinot.common.request.FilterQueryMap;
 import org.apache.pinot.common.request.GroupBy;
+import org.apache.pinot.common.request.PinotQuery;
 import org.apache.pinot.common.request.QuerySource;
 import org.apache.pinot.common.request.QueryType;
 import org.apache.pinot.common.request.Selection;
 import org.apache.pinot.common.request.SelectionSort;
+import org.apache.pinot.common.utils.request.RequestUtils;
+import org.apache.pinot.pql.parsers.pql2.ast.StringLiteralAstNode;
 import org.apache.thrift.TException;
 import org.apache.thrift.TSerializer;
 import org.apache.thrift.protocol.TCompactProtocol;
@@ -127,4 +132,142 @@ public class BrokerRequestSerializationTest {
 //    t.stop();
 //    System.out.println("Latency is :" + (t.getLatencyMs() / (float) numRequests));
   }
+
+  @Test
+  public static void testSerializationWithPinotQuery()
+      throws TException {
+    BrokerRequest req = new BrokerRequest();
+
+    // START Set PinotQuery
+    PinotQuery pinotQuery = new PinotQuery();
+
+    // Populate Query source
+    DataSource dataSource = new DataSource();
+    dataSource.setTableName("dummy");
+    pinotQuery.setDataSource(dataSource);
+
+    //Populate Group-By
+
+    List<Expression> groupByList = new ArrayList<>();
+    groupByList.add(RequestUtils.createIdentifierExpression("dummy1"));
+    groupByList.add(RequestUtils.createIdentifierExpression("dummy2"));
+    pinotQuery.setGroupByList(groupByList);
+    pinotQuery.setLimit(100);
+
+    //Populate Selections
+    pinotQuery.addToSelectList(RequestUtils.createIdentifierExpression("dummy1"));
+
+    //Populate OrderBy
+    Expression ascExpr = RequestUtils.createFunctionExpression("asc");
+    ascExpr.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression("dummy1"));
+    pinotQuery.addToOrderByList(ascExpr);
+
+    //Populate FilterQuery
+    Expression filter = RequestUtils.createFunctionExpression(FilterOperator.AND.name());
+
+    Expression filterExpr1 = RequestUtils.createFunctionExpression(FilterOperator.EQUALITY.name());
+    filterExpr1.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression("dummy1"));
+    filterExpr1.getFunctionCall().addToOperands(RequestUtils.createLiteralExpression(new StringLiteralAstNode("dummy1")));
+    filter.getFunctionCall().addToOperands(filterExpr1);
+
+    Expression filterExpr2 = RequestUtils.createFunctionExpression(FilterOperator.EQUALITY.name());
+    filterExpr2.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression("dummy2"));
+    filterExpr2.getFunctionCall().addToOperands(RequestUtils.createLiteralExpression(new StringLiteralAstNode("dummy2")));
+    filter.getFunctionCall().addToOperands(filterExpr2);
+
+    pinotQuery.setFilterExpression(filter);
+
+    //Populate Aggregations
+    Expression aggExpr = RequestUtils.createFunctionExpression("dummy1");
+    aggExpr.getFunctionCall().addToOperands(RequestUtils.createIdentifierExpression("dummy"));
+    pinotQuery.addToSelectList(aggExpr);
+
+    req.setPinotQuery(pinotQuery);
+
+    // END Set PinotQuery
+
+    // Populate Query Type
+    QueryType type = new QueryType();
+    type.setHasAggregation(true);
+    type.setHasFilter(true);
+    type.setHasSelection(true);
+    type.setHasGroup_by(true);
+    req.setQueryType(type);
+
+    // Populate Query source
+    QuerySource s = new QuerySource();
+    s.setTableName("dummy");
+    req.setQuerySource(s);
+
+    req.setDuration("dummy");
+    req.setTimeInterval("dummy");
+
+    //Populate Group-By
+    GroupBy groupBy = new GroupBy();
+    List<String> columns = new ArrayList<String>();
+    columns.add("dummy1");
+    columns.add("dummy2");
+    groupBy.setColumns(columns);
+    groupBy.setTopN(100);
+    req.setGroupBy(groupBy);
+
+    //Populate Selections
+    Selection sel = new Selection();
+    sel.setSize(1);
+    SelectionSort s2 = new SelectionSort();
+    s2.setColumn("dummy1");
+    s2.setIsAsc(true);
+    sel.addToSelectionSortSequence(s2);
+    sel.addToSelectionColumns("dummy1");
+    req.setSelections(sel);
+
+    //Populate FilterQuery
+    FilterQuery q1 = new FilterQuery();
+    q1.setId(1);
+    q1.setColumn("dummy1");
+    q1.addToValue("dummy1");
+    q1.addToNestedFilterQueryIds(2);
+    q1.setOperator(FilterOperator.AND);
+    FilterQuery q2 = new FilterQuery();
+    q2.setId(2);
+    q2.setColumn("dummy2");
+    q2.addToValue("dummy2");
+    q2.setOperator(FilterOperator.AND);
+
+    FilterQueryMap map = new FilterQueryMap();
+    map.putToFilterQueryMap(1, q1);
+    map.putToFilterQueryMap(2, q2);
+    req.setFilterQuery(q1);
+    req.setFilterSubQueryMap(map);
+
+    //Populate Aggregations
+    AggregationInfo agg = new AggregationInfo();
+    agg.setAggregationType("dummy1");
+    agg.putToAggregationParams("key1", "dummy1");
+    req.addToAggregationsInfo(agg);
+
+    TSerializer normalSerializer = new TSerializer();
+    TSerializer compactSerializer = new TSerializer(new TCompactProtocol.Factory());
+    normalSerializer.serialize(req);
+    compactSerializer.serialize(req);
+
+//    int numRequests = 100000;
+//    TimerContext t = MetricsHelper.startTimer();
+//    TSerializer serializer = new TSerializer(new TCompactProtocol.Factory());
+//    //TSerializer serializer = new TSerializer();
+//    //Compact : Size 183 , Serialization Latency : 0.03361ms
+//    // Normal : Size 385 , Serialization Latency : 0.01144ms
+//
+//    for (int i = 0; i < numRequests; i++) {
+//      try {
+//        serializer.serialize(req);
+//        //System.out.println(s3.length);
+//        //break;
+//      } catch (TException e) {
+//        e.printStackTrace();
+//      }
+//    }
+//    t.stop();
+//    System.out.println("Latency is :" + (t.getLatencyMs() / (float) numRequests));
+  }
 }
diff --git a/pinot-common/src/test/resources/pql_queries.list b/pinot-common/src/test/resources/pql_queries.list
new file mode 100644
index 0000000..9d3b0d9
--- /dev/null
+++ b/pinot-common/src/test/resources/pql_queries.list
@@ -0,0 +1,814 @@
+SELECT *  FROM testTable ORDER BY column6, column1
+SELECT *  FROM testTable ORDER BY column6, column1 WHERE column1 > 100000000 AND column3 BETWEEN 20000000 AND 1000000000 AND column5 = 'gFuH' AND (column6 < 500000000 OR column11 NOT IN ('t', 'P')) AND daysSinceEpoch = 126164076
+SELECT * FROM testTable LIMIT 0
+SELECT * FROM testTable LIMIT 0 WHERE column1 > 100000000 AND column2 BETWEEN 20000000 AND 1000000000 AND column3 <> 'w' AND (column6 < 500000 OR column7 NOT IN (225, 407)) AND daysSinceEpoch = 1756015683
+SELECT * FROM testTable LIMIT 0 WHERE column1 > 100000000 AND column3 BETWEEN 20000000 AND 1000000000 AND column5 = 'gFuH' AND (column6 < 500000000 OR column11 NOT IN ('t', 'P')) AND daysSinceEpoch = 126164076
+SELECT ActualElapsedTime FROM mytable WHERE  REGEXP_LIKE(OriginCityName, 'Pon.*e, PR') ORDER BY CancellationCode LIMIT 14
+SELECT ActualElapsedTime FROM mytable WHERE LateAircraftDelay > 98 AND DestWac BETWEEN 15 AND 66 AND TailNum BETWEEN 'N843MQ' AND 'N14916' ORDER BY WeatherDelay LIMIT 22
+SELECT ActualElapsedTime, ArrTime, TailNum FROM mytable LIMIT 16
+SELECT ActualElapsedTime, CancellationCode FROM mytable WHERE OriginCityName <= 'Hibbing, MN' ORDER BY FlightNum LIMIT 24
+SELECT ActualElapsedTime, CancellationCode FROM mytable WHERE Year BETWEEN 2014 AND 2014 ORDER BY Flights, DepTimeBlk, DaysSinceEpoch LIMIT 3
+SELECT ActualElapsedTime, DaysSinceEpoch FROM mytable LIMIT 4
+SELECT ActualElapsedTime, Dest, DestState FROM mytable WHERE OriginWac BETWEEN 85 AND 83 ORDER BY CRSDepTime, CancellationCode LIMIT 3
+SELECT ActualElapsedTime, DestStateFips FROM mytable ORDER BY FlightDate LIMIT 7
+SELECT ActualElapsedTime, DivWheelsOffs FROM mytable WHERE DivDistance BETWEEN 328 AND 334 AND DestCityMarketID IN (31641, 31337, 31205, 30107) ORDER BY DivActualElapsedTime LIMIT 8
+SELECT ActualElapsedTime, DivWheelsOffs FROM mytable WHERE OriginCityName < 'Hayden, CO' LIMIT 10
+SELECT ActualElapsedTime, DivWheelsOns FROM mytable WHERE Month BETWEEN 5 AND 6 AND DepartureDelayGroups <= 4 LIMIT 28
+SELECT ActualElapsedTime, FlightDate, ArrDel15 FROM mytable WHERE ArrivalDelayGroups NOT IN (0) OR  REGEXP_LIKE(OriginStateName, 'U.S. Pacific Trust Terr.*tories and Possessions') ORDER BY CancellationCode, CRSArrTime LIMIT 12
+SELECT ActualElapsedTime, Month, DivActualElapsedTime FROM mytable WHERE CarrierDelay IN (80) OR DestStateName <= 'Tennessee' LIMIT 21
+SELECT ActualElapsedTime, NASDelay FROM mytable WHERE Year BETWEEN 2014 AND 2014 AND LateAircraftDelay NOT IN (199, 60, 362) AND Year BETWEEN 2014 AND 2014 ORDER BY CancellationCode, DestAirportID, OriginAirportID LIMIT 1
+SELECT ActualElapsedTime, OriginAirportSeqID, AirTime FROM mytable WHERE Diverted BETWEEN 0 AND 0 OR DivLongestGTimes IN (172.0, 99.0, 154.0, 48.0) LIMIT 16
+SELECT ActualElapsedTime, OriginCityName, ArrivalDelayGroups FROM mytable WHERE TailNum BETWEEN 'N637MQ' AND 'N564AS' ORDER BY DivReachedDest LIMIT 15
+SELECT AirTime FROM mytable ORDER BY ActualElapsedTime, DepDel15 LIMIT 24
+SELECT AirTime FROM mytable WHERE  REGEXP_LIKE(DepTimeBlk, '09.*0-0959') OR DivTotalGTimes BETWEEN 26 AND 71 AND CRSDepTime = 2 ORDER BY Origin, WheelsOn LIMIT 4
+SELECT AirTime FROM mytable WHERE  REGEXP_LIKE(OriginCityName, 'Bemidji, M.*') AND Month BETWEEN 7 AND 10 LIMIT 13
+SELECT AirTime FROM mytable WHERE Diverted <= 0 ORDER BY Origin, DivAirportLandings LIMIT 10
+SELECT AirTime FROM mytable WHERE TaxiIn = 20 AND SecurityDelay <= 14 AND DivAirports IN ('SGF', 'MOB', 'APA', 'BLI') ORDER BY CancellationCode LIMIT 15
+SELECT AirTime, DepTimeBlk, TotalAddGTime FROM mytable WHERE OriginCityName BETWEEN 'Santa Ana, CA' AND 'Klamath Falls, OR' OR TaxiOut <> 21 AND WheelsOn = 1518 ORDER BY Quarter, OriginStateFips LIMIT 8
+SELECT AirTime, DestCityMarketID FROM mytable WHERE DestWac NOT IN (67, 51, 82, 73, 14) ORDER BY SecurityDelay LIMIT 13
+SELECT AirTime, UniqueCarrier, DestStateFips FROM mytable ORDER BY Month LIMIT 11
+SELECT AirlineID FROM mytable WHERE CRSElapsedTime = 152 OR DayOfWeek <> 4 AND  REGEXP_LIKE(UniqueCarrier, '.*L') ORDER BY FirstDepTime, ArrTimeBlk, DepTime LIMIT 3
+SELECT AirlineID FROM mytable WHERE DepTime <> 631 OR DaysSinceEpoch = 16148 OR  REGEXP_LIKE(Origin, 'O.*J') ORDER BY ArrDel15, DivReachedDest, WeatherDelay LIMIT 27
+SELECT AirlineID FROM mytable WHERE NASDelay <> 6 ORDER BY Month, AirTime, DepTimeBlk LIMIT 29
+SELECT AirlineID FROM mytable WHERE Quarter BETWEEN 1 AND 1 AND DestAirportSeqID BETWEEN 1029904 AND 1219702 OR DivTotalGTimes BETWEEN 63 AND 90 LIMIT 24
+SELECT AirlineID, Dest, TaxiOut FROM mytable WHERE SecurityDelay = 5 AND OriginState IN ('KS', 'CT', 'TX') OR DestCityMarketID >= 30285 ORDER BY FirstDepTime LIMIT 0
+SELECT AirlineID, DivLongestGTimes, DepDelayMinutes FROM mytable WHERE DivWheelsOns >= 1816 ORDER BY CancellationCode LIMIT 10
+SELECT AirlineID, OriginStateName FROM mytable ORDER BY Year LIMIT 25
+SELECT AirlineID, WheelsOff FROM mytable WHERE DestState = 'MI' AND FlightNum = 3060 ORDER BY OriginStateName, Distance, DestCityName LIMIT 10
+SELECT ArrDel15 FROM mytable ORDER BY AirTime LIMIT 20
+SELECT ArrDel15 FROM mytable ORDER BY OriginCityName, ArrTime, ArrDelayMinutes LIMIT 18
+SELECT ArrDel15 FROM mytable WHERE DestWac < 66 ORDER BY FirstDepTime, FlightNum, Cancelled LIMIT 19
+SELECT ArrDel15 FROM mytable WHERE OriginStateFips BETWEEN 42 AND 19 OR DivReachedDest < 0 OR WheelsOff BETWEEN 1202 AND 1218 ORDER BY DivDistance LIMIT 29
+SELECT ArrDel15, DestStateName FROM mytable WHERE Month NOT IN (12) LIMIT 23
+SELECT ArrDel15, TaxiOut FROM mytable WHERE DepTime BETWEEN 1657 AND 233 ORDER BY OriginAirportSeqID, DivReachedDest, TailNum LIMIT 0
+SELECT ArrDel15, UniqueCarrier FROM mytable WHERE OriginWac < 14 OR DivReachedDest = 1 AND Dest BETWEEN 'SAV' AND 'GSO' ORDER BY OriginCityMarketID, DayofMonth LIMIT 8
+SELECT ArrDel15, WeatherDelay FROM mytable ORDER BY DepDel15 LIMIT 24
+SELECT ArrDelay FROM mytable ORDER BY ArrDelay LIMIT 15
+SELECT ArrDelay FROM mytable WHERE  REGEXP_LIKE(DestStateName, 'Ind.*ana') ORDER BY ActualElapsedTime, TailNum LIMIT 0
+SELECT ArrDelay FROM mytable WHERE DestState >= 'VI' AND DivLongestGTimes = 66.0 AND Quarter = 1 ORDER BY AirTime, ArrTimeBlk LIMIT 27
+SELECT ArrDelay FROM mytable WHERE OriginState BETWEEN 'NV' AND 'CO' AND ArrTime NOT IN (1304, 1211, 1724) ORDER BY FlightDate, DivActualElapsedTime LIMIT 21
+SELECT ArrDelay, ArrivalDelayGroups, ArrTimeBlk FROM mytable WHERE DestState IN ('AZ', 'NE', 'WY', 'VI') OR DestCityName < 'Laredo, TX' OR DestCityMarketID <> 33795 ORDER BY DestAirportID LIMIT 28
+SELECT ArrDelay, CancellationCode FROM mytable ORDER BY OriginAirportSeqID LIMIT 7
+SELECT ArrDelay, Month, OriginStateName FROM mytable ORDER BY DepartureDelayGroups, SecurityDelay LIMIT 26
+SELECT ArrDelayMinutes, DestWac FROM mytable WHERE DaysSinceEpoch > 16238 OR DistanceGroup BETWEEN 4 AND 3 ORDER BY FlightDate, DistanceGroup, UniqueCarrier LIMIT 21
+SELECT ArrDelayMinutes, WheelsOn FROM mytable WHERE DivAirportLandings NOT IN (2, 0, 9) AND DivWheelsOffs IN (842, 1816, 2152, 1907) AND Dest <> 'PIT' ORDER BY OriginAirportSeqID, DepartureDelayGroups, DestAirportID LIMIT 13
+SELECT ArrTime FROM mytable WHERE ArrDel15 NOT IN (1, -9999) AND UniqueCarrier BETWEEN 'HA' AND 'WN' ORDER BY TotalAddGTime LIMIT 9
+SELECT ArrTime FROM mytable WHERE SecurityDelay BETWEEN 17 AND 17 AND TaxiIn = 116 OR TotalAddGTime BETWEEN 4 AND 80 LIMIT 20
+SELECT ArrTime FROM mytable WHERE WheelsOn NOT IN (1511, 627) ORDER BY OriginAirportSeqID, OriginStateFips, Cancelled LIMIT 12
+SELECT ArrTime FROM mytable WHERE Year IN (2014) OR ArrTime BETWEEN 244 AND 637 AND UniqueCarrier BETWEEN 'VX' AND 'US' ORDER BY Quarter
+SELECT ArrTime, AirTime FROM mytable WHERE DayOfWeek BETWEEN 1 AND 7 AND FirstDepTime IN (1032, 2145, 1940, -9999) LIMIT 23
+SELECT ArrTime, ArrDelayMinutes, DestCityName FROM mytable WHERE TotalAddGTime <= 26 LIMIT 10
+SELECT ArrTime, DestStateName FROM mytable ORDER BY Flights, CRSElapsedTime LIMIT 9
+SELECT ArrTime, DestStateName, DestCityName FROM mytable WHERE LongestAddGTime NOT IN (48) OR DestCityName IN ('Lake Charles, LA', 'College Station/Bryan, TX', 'Sun Valley/Hailey/Ketchum, ID', 'Tucson, AZ') AND NASDelay <> 87 ORDER BY OriginAirportID LIMIT 25
+SELECT ArrTime, DistanceGroup, DivAirportSeqIDs FROM mytable ORDER BY LongestAddGTime, DestState, Cancelled LIMIT 8
+SELECT ArrTime, DivAirportIDs, CancellationCode FROM mytable ORDER BY OriginCityMarketID, ArrDel15 LIMIT 4
+SELECT ArrTime, OriginState, DestStateName FROM mytable WHERE DivActualElapsedTime = 607 OR  REGEXP_LIKE(Origin, '.*GG') ORDER BY DivAirportLandings, OriginCityName, DestState LIMIT 19
+SELECT ArrTimeBlk FROM mytable ORDER BY CRSDepTime, FirstDepTime LIMIT 21
+SELECT ArrTimeBlk FROM mytable ORDER BY CarrierDelay LIMIT 13
+SELECT ArrTimeBlk FROM mytable WHERE SecurityDelay NOT IN (0, 4, 8, 14, -9999) AND DayofMonth < 28 AND TotalAddGTime = 51 ORDER BY DivDistance, CRSDepTime LIMIT 29
+SELECT ArrivalDelayGroups FROM mytable WHERE DepartureDelayGroups BETWEEN 1 AND -1 ORDER BY TotalAddGTime, TailNum, DivArrDelay LIMIT 18
+SELECT COUNT(*) FROM mytable GROUP BY add(DaysSinceEpoch,DaysSinceEpoch,15)
+SELECT COUNT(*) FROM mytable GROUP BY div(DaysSinceEpoch,2)
+SELECT COUNT(*) FROM mytable GROUP BY mult(DaysSinceEpoch,24,3600)
+SELECT COUNT(*) FROM mytable GROUP BY sub(DaysSinceEpoch,25)
+SELECT CRSArrTime FROM mytable ORDER BY OriginAirportSeqID, ArrTime, OriginAirportID LIMIT 15
+SELECT CRSArrTime FROM mytable WHERE CRSDepTime IN (808, 45, 1850, 1809, 2240) LIMIT 22
+SELECT CRSArrTime FROM mytable WHERE Carrier BETWEEN 'OO' AND 'AS' ORDER BY Distance, ArrTimeBlk LIMIT 4
+SELECT CRSArrTime FROM mytable WHERE DayofMonth > 19 AND DestStateName BETWEEN 'Hawaii' AND 'New York' LIMIT 29
+SELECT CRSArrTime FROM mytable WHERE DestStateFips IN (20, 10, 30, 32) LIMIT 12
+SELECT CRSArrTime FROM mytable WHERE NASDelay <= 63 AND AirTime NOT IN (208) OR DivReachedDest NOT IN (1, -9999) ORDER BY TaxiOut LIMIT 22
+SELECT CRSArrTime, AirTime FROM mytable WHERE DivAirports BETWEEN 'TWF' AND 'RFD' OR ArrDelay BETWEEN 363.0 AND 159.0 OR OriginStateName BETWEEN 'Alabama' AND 'Oregon' ORDER BY Year, Month LIMIT 16
+SELECT CRSArrTime, ArrDelay, DestAirportID FROM mytable WHERE WheelsOff <= 142 OR Distance NOT IN (1092) ORDER BY DivAirportLandings, FirstDepTime, ArrTime LIMIT 28
+SELECT CRSArrTime, ArrDelayMinutes, DivAirportSeqIDs FROM mytable WHERE Month IN (1) AND ArrDel15 BETWEEN 0 AND 0 AND DivTailNums BETWEEN 'N636MQ' AND 'N16976' LIMIT 26
+SELECT CRSArrTime, ArrivalDelayGroups FROM mytable WHERE Diverted > 0 ORDER BY DivAirportLandings LIMIT 28
+SELECT CRSArrTime, FlightDate FROM mytable WHERE OriginStateName IN ('Washington') AND OriginAirportID IN (12007, 12888, 12206, 11122, 10693) AND Diverted IN (1, 0) ORDER BY DepDelay, DestAirportSeqID LIMIT 21
+SELECT CRSArrTime, SecurityDelay, ArrTimeBlk FROM mytable WHERE ArrTime IN (2302) AND OriginCityName BETWEEN 'Kona, HI' AND 'New York, NY' ORDER BY FlightNum LIMIT 17
+SELECT CRSArrTime, WheelsOn FROM mytable WHERE DivLongestGTimes BETWEEN 112.0 AND 39.0 LIMIT 8
+SELECT CRSDepTime FROM mytable ORDER BY FlightNum LIMIT 14
+SELECT CRSDepTime FROM mytable WHERE TaxiOut NOT IN (55) OR Distance NOT IN (985) OR OriginCityMarketID >= 31041 ORDER BY DestWac, DestStateName, OriginStateName LIMIT 28
+SELECT CRSDepTime, Carrier, DayofMonth FROM mytable WHERE Distance NOT IN (1679, 1368, 334, 727, 1290) AND DistanceGroup = 5 AND DivWheelsOns >= 2301 ORDER BY Dest LIMIT 18
+SELECT CRSDepTime, DestAirportID FROM mytable WHERE OriginStateFips <= 37 ORDER BY AirTime, DivReachedDest
+SELECT CRSDepTime, DestState, DivAirportSeqIDs FROM mytable WHERE DestStateFips NOT IN (24) AND DepDelayMinutes IN (20.0) ORDER BY FirstDepTime LIMIT 23
+SELECT CRSDepTime, DivAirportLandings FROM mytable ORDER BY OriginWac, AirTime, CRSArrTime LIMIT 9
+SELECT CRSDepTime, DivLongestGTimes FROM mytable ORDER BY OriginWac, DestAirportSeqID LIMIT 1
+SELECT CRSDepTime, DivTotalGTimes, OriginStateName FROM mytable WHERE DepDel15 > 0 AND Year <> 2014 OR DaysSinceEpoch BETWEEN 16082 AND 16086 ORDER BY Cancelled, DestAirportID LIMIT 24
+SELECT CRSDepTime, DivWheelsOffs, Diverted FROM mytable WHERE DepDel15 <= 0 OR OriginCityName BETWEEN 'Scranton/Wilkes-Barre, PA' AND 'Abilene, TX' ORDER BY Month, OriginCityName LIMIT 27
+SELECT CRSDepTime, OriginWac, DestCityName FROM mytable ORDER BY SecurityDelay
+SELECT CRSDepTime, TailNum, OriginAirportID FROM mytable WHERE DepartureDelayGroups NOT IN (12) OR FlightDate > '2014-09-10' ORDER BY DivAirportLandings, CRSElapsedTime, Diverted LIMIT 3
+SELECT CRSDepTime, TaxiIn, ArrTime FROM mytable WHERE DestAirportSeqID = 1379502 ORDER BY CRSArrTime, Carrier LIMIT 13
+SELECT CRSElapsedTime, DestWac FROM mytable WHERE DivLongestGTimes < 189.0 ORDER BY Dest, TotalAddGTime LIMIT 4
+SELECT CRSElapsedTime, OriginAirportID FROM mytable LIMIT 27
+SELECT CRSElapsedTime, OriginAirportID FROM mytable WHERE DepTimeBlk NOT IN ('1800-1859', '1300-1359', '2200-2259') AND DayOfWeek = 7 OR LateAircraftDelay = 78 ORDER BY OriginCityMarketID, LongestAddGTime, DivDistance LIMIT 1
+SELECT CancellationCode FROM mytable LIMIT 29
+SELECT CancellationCode FROM mytable ORDER BY SecurityDelay, AirTime
+SELECT CancellationCode FROM mytable WHERE AirTime > 233 ORDER BY WeatherDelay, DestAirportSeqID, OriginWac LIMIT 8
+SELECT CancellationCode FROM mytable WHERE AirTime NOT IN (204, 96, 277, 252) AND OriginAirportSeqID NOT IN (1148102) ORDER BY DestWac, DestAirportID LIMIT 11
+SELECT CancellationCode FROM mytable WHERE DestCityName NOT IN ('Detroit, MI') ORDER BY FlightNum, WheelsOn, Month LIMIT 17
+SELECT CancellationCode, ArrivalDelayGroups, ArrTimeBlk FROM mytable WHERE CRSDepTime = 1050 OR DepDelayMinutes BETWEEN 207.0 AND 88.0 ORDER BY OriginAirportSeqID, DestAirportID LIMIT 24
+SELECT CancellationCode, DepDelay, WeatherDelay FROM mytable WHERE DivArrDelay > 866 ORDER BY FlightNum LIMIT 17
+SELECT CancellationCode, DestState, CRSElapsedTime FROM mytable ORDER BY CancellationCode LIMIT 22
+SELECT CancellationCode, DivActualElapsedTime FROM mytable ORDER BY OriginStateFips, DestAirportSeqID, AirlineID LIMIT 9
+SELECT CancellationCode, DivTailNums, DestCityMarketID FROM mytable WHERE DivReachedDest BETWEEN 0 AND -9999 OR Cancelled BETWEEN 1 AND 0 ORDER BY Year, OriginState LIMIT 7
+SELECT CancellationCode, Diverted FROM mytable ORDER BY ArrDelayMinutes, TaxiOut, DestAirportID LIMIT 0
+SELECT CancellationCode, OriginAirportSeqID, CRSArrTime FROM mytable WHERE Month BETWEEN 5 AND 1 LIMIT 9
+SELECT CancellationCode, WeatherDelay, Cancelled FROM mytable WHERE OriginWac > 61 OR Distance BETWEEN 636 AND 223 AND DivAirportLandings <> 1 ORDER BY DivReachedDest LIMIT 7
+SELECT Cancelled FROM mytable ORDER BY AirlineID, WheelsOn LIMIT 27
+SELECT Cancelled FROM mytable WHERE CRSElapsedTime BETWEEN 365 AND 160 LIMIT 14
+SELECT Cancelled FROM mytable WHERE CarrierDelay BETWEEN 144 AND 12 OR DestWac NOT IN (2, 93) OR DivDistance <> 89 ORDER BY OriginAirportSeqID, Diverted, DepTime LIMIT 9
+SELECT Cancelled FROM mytable WHERE DestWac <= 14 AND ArrTime IN (2329, 1417) OR DivTotalGTimes = 84 ORDER BY OriginCityMarketID, ActualElapsedTime, Origin LIMIT 21
+SELECT Cancelled FROM mytable WHERE TotalAddGTime IN (42) OR ArrDelayMinutes IN (193.0, 52.0, 382.0, 392.0, 147.0) AND DayOfWeek = 3 ORDER BY FlightNum, ArrivalDelayGroups, DepTime LIMIT 25
+SELECT Cancelled, ArrDel15, CRSElapsedTime FROM mytable WHERE DivWheelsOffs >= 851 AND Month BETWEEN 1 AND 1 ORDER BY WheelsOff, ArrivalDelayGroups LIMIT 6
+SELECT Cancelled, CancellationCode FROM mytable WHERE DestStateFips BETWEEN 24 AND 34 AND AirTime IN (202, 357, 172, 192) AND DestCityMarketID <> 31308 ORDER BY DepDelay, Carrier LIMIT 23
+SELECT Cancelled, DestAirportID FROM mytable WHERE DivAirports BETWEEN 'DRO' AND 'CDC' AND DestState NOT IN ('CO', 'NY') ORDER BY Distance
+SELECT Cancelled, DivAirportLandings FROM mytable WHERE Origin NOT IN ('OGG', 'EVV', 'SAT') AND DepartureDelayGroups IN (2) AND Origin NOT IN ('IMT', 'MGM', 'ALB', 'ROW') LIMIT 7
+SELECT Carrier FROM mytable ORDER BY DivArrDelay LIMIT 28
+SELECT Carrier FROM mytable ORDER BY DivArrDelay, Dest, OriginAirportSeqID LIMIT 2
+SELECT Carrier FROM mytable WHERE OriginStateName < 'Mississippi' AND CancellationCode BETWEEN 'A' AND 'noodles' OR SecurityDelay BETWEEN 16 AND 17 ORDER BY CancellationCode, Year, WeatherDelay LIMIT 5
+SELECT Carrier, AirlineID FROM mytable WHERE DayOfWeek BETWEEN 4 AND 6 AND ArrDelayMinutes NOT IN (143.0) OR FlightDate BETWEEN '2014-01-11' AND '2014-01-18' LIMIT 21
+SELECT Carrier, ArrDel15, DayOfWeek FROM mytable WHERE ArrDelayMinutes >= 116.0 AND DivTailNums IN ('N3HHAA') OR ArrivalDelayGroups BETWEEN 1 AND -1 LIMIT 3
+SELECT Carrier, ArrTime, DestCityMarketID FROM mytable WHERE TailNum NOT IN ('N5ELAA', 'N788AS', 'N558AA') OR CRSArrTime NOT IN (1232, 1924) AND DestStateName NOT IN ('Alaska', 'Rhode Island') LIMIT 23
+SELECT Carrier, CRSArrTime, UniqueCarrier FROM mytable WHERE DestStateName BETWEEN 'Nebraska' AND 'Illinois' OR DayOfWeek > 3 ORDER BY DivArrDelay LIMIT 20
+SELECT Carrier, CRSElapsedTime, DayOfWeek FROM mytable WHERE Diverted BETWEEN 0 AND 1 OR Month <> 1 AND DivActualElapsedTime <> 469 ORDER BY AirTime LIMIT 25
+SELECT Carrier, Cancelled FROM mytable WHERE DivTailNums <= 'N486WN' ORDER BY TaxiOut LIMIT 19
+SELECT Carrier, DestAirportSeqID FROM mytable ORDER BY FlightDate LIMIT 14
+SELECT Carrier, Distance, DaysSinceEpoch FROM mytable WHERE CancellationCode BETWEEN 'A' AND 'C' OR FirstDepTime BETWEEN 1738 AND 2104 ORDER BY OriginCityMarketID, DivActualElapsedTime LIMIT 2
+SELECT Carrier, OriginAirportID FROM mytable WHERE DivAirportSeqIDs IN (1385103, 1302402) ORDER BY OriginState LIMIT 25
+SELECT Carrier, OriginWac FROM mytable WHERE ActualElapsedTime BETWEEN 396 AND 86 AND FirstDepTime = 857 ORDER BY AirlineID, DivArrDelay LIMIT 24
+SELECT Carrier, WheelsOn FROM mytable ORDER BY TaxiIn, DestCityName, CRSDepTime LIMIT 23
+SELECT CarrierDelay FROM mytable LIMIT 22
+SELECT CarrierDelay FROM mytable ORDER BY CarrierDelay LIMIT 17
+SELECT CarrierDelay, ArrDelayMinutes, TotalAddGTime FROM mytable WHERE AirTime = 404 OR CancellationCode > 'B' OR DestState >= 'AZ' ORDER BY DivDistance, DepDelayMinutes LIMIT 12
+SELECT CarrierDelay, ArrivalDelayGroups FROM mytable WHERE Dest <> 'CVG' AND OriginCityMarketID IN (33344, 34945, 34992) LIMIT 14
+SELECT CarrierDelay, DepTimeBlk, TailNum FROM mytable WHERE CarrierDelay = 163 ORDER BY Month, OriginCityName, NASDelay LIMIT 8
+SELECT CarrierDelay, DestAirportID FROM mytable WHERE DepTime IN (253, 1831, 1154, 309) AND Origin > 'ISN' LIMIT 3
+SELECT CarrierDelay, DestCityMarketID, DestCityName FROM mytable WHERE DayofMonth BETWEEN 27 AND 19 OR  REGEXP_LIKE(Origin, '.*WM') OR DestAirportSeqID = 1201602 LIMIT 19
+SELECT CarrierDelay, DestStateFips, ActualElapsedTime FROM mytable WHERE Year NOT IN (2014) OR OriginAirportSeqID IN (1541202) OR DestWac NOT IN (51) ORDER BY TaxiIn, DaysSinceEpoch LIMIT 6
+SELECT CarrierDelay, DistanceGroup, ArrivalDelayGroups FROM mytable WHERE DepDelayMinutes <> 98.0 AND DivAirportLandings BETWEEN 2 AND 0 ORDER BY OriginStateFips, ArrDel15 LIMIT 16
+SELECT CarrierDelay, DistanceGroup, DaysSinceEpoch FROM mytable WHERE CRSArrTime > 1232 OR NASDelay = 146 OR DivWheelsOffs <= 1413 ORDER BY DivDistance, DestStateName LIMIT 12
+SELECT CarrierDelay, DivTotalGTimes FROM mytable WHERE Year BETWEEN 2014 AND 2014 AND Cancelled >= 1 ORDER BY ActualElapsedTime, DepTime LIMIT 21
+SELECT CarrierDelay, DivWheelsOffs FROM mytable WHERE ArrDel15 BETWEEN -9999 AND 1 AND DestAirportSeqID = 1251902 ORDER BY DepartureDelayGroups, TailNum LIMIT 19
+SELECT CarrierDelay, DivWheelsOffs FROM mytable WHERE DayOfWeek BETWEEN 5 AND 2 AND DepDelayMinutes NOT IN (114.0, 89.0, 91.0, 75.0) LIMIT 4
+SELECT CarrierDelay, FirstDepTime FROM mytable LIMIT 25
+SELECT CarrierDelay, Origin, DayOfWeek FROM mytable WHERE ActualElapsedTime BETWEEN 163 AND 322 OR CarrierDelay IN (17, 266) OR AirlineID IN (19690, 20366) ORDER BY TaxiIn, TailNum LIMIT 1
+SELECT CarrierDelay, OriginStateFips FROM mytable WHERE  REGEXP_LIKE(OriginCityName, 'Aberdeen,.*SD') AND CRSArrTime >= 1733 ORDER BY WeatherDelay LIMIT 9
+SELECT DayOfWeek FROM mytable WHERE DepDelayMinutes IN (227.0, 332.0, 174.0, 38.0) AND CRSDepTime BETWEEN 726 AND 1806 ORDER BY DepartureDelayGroups, TailNum, DestCityName LIMIT 29
+SELECT DayOfWeek FROM mytable WHERE FirstDepTime >= 1940 ORDER BY OriginCityMarketID, DaysSinceEpoch LIMIT 12
+SELECT DayOfWeek FROM mytable WHERE WheelsOn < 314 LIMIT 8
+SELECT DayOfWeek, Carrier, TailNum FROM mytable ORDER BY DivActualElapsedTime, WeatherDelay LIMIT 23
+SELECT DayOfWeek, DepDel15, DivTotalGTimes FROM mytable WHERE  REGEXP_LIKE(DestState, '.*D') ORDER BY AirlineID, LongestAddGTime LIMIT 18
+SELECT DayOfWeek, DestStateFips, WheelsOn FROM mytable WHERE FlightDate BETWEEN '2014-01-02' AND '2014-12-22' OR Month NOT IN (12, 1, 3, 5, 10) OR CRSArrTime NOT IN (448, 1150) LIMIT 20
+SELECT DayOfWeek, DivActualElapsedTime FROM mytable ORDER BY Distance LIMIT 0
+SELECT DayOfWeek, DivAirports FROM mytable ORDER BY DivArrDelay, WeatherDelay LIMIT 28
+SELECT DayOfWeek, DivTailNums, Distance FROM mytable WHERE OriginAirportID NOT IN (13891, 14842) AND DivWheelsOffs >= 327 OR OriginStateFips = 35 LIMIT 13
+SELECT DayOfWeek, FlightDate, OriginStateFips FROM mytable WHERE DestAirportID BETWEEN 14524 AND 11413 OR LongestAddGTime = 83 AND OriginWac = 83 ORDER BY ActualElapsedTime, CRSDepTime, ArrDelay LIMIT 15
+SELECT DayOfWeek, LongestAddGTime, TaxiOut FROM mytable WHERE DepTime = 710 AND CarrierDelay >= 197 AND DepDelayMinutes NOT IN (294.0, 916.0, 242.0, 38.0) ORDER BY DivActualElapsedTime, DepDelayMinutes, ArrDelay LIMIT 25
+SELECT DayOfWeek, OriginWac, OriginStateFips FROM mytable WHERE FirstDepTime >= 1252 AND FlightDate IN ('2014-02-14', '2014-03-25') OR TotalAddGTime IN (157, 169, 105, 41) ORDER BY WheelsOn LIMIT 8
+SELECT DayOfWeek, TailNum FROM mytable ORDER BY DepDel15, WheelsOn LIMIT 18
+SELECT DayOfWeek, TaxiIn FROM mytable LIMIT 14
+SELECT DayofMonth, OriginWac, DivArrDelay FROM mytable WHERE CRSArrTime BETWEEN 1743 AND 2103 ORDER BY Year, Quarter, ArrivalDelayGroups LIMIT 17
+SELECT DaysSinceEpoch FROM mytable WHERE DistanceGroup <= 2 AND OriginState IN ('VA', 'ME', 'MN', 'VI') AND AirlineID <> 19690 ORDER BY DestState, DestStateFips LIMIT 13
+SELECT DaysSinceEpoch FROM mytable WHERE DivWheelsOns >= 623 ORDER BY DestAirportSeqID, ArrTimeBlk LIMIT 22
+SELECT DepDel15 FROM mytable WHERE DepDelayMinutes = 205.0 LIMIT 11
+SELECT DepDel15 FROM mytable WHERE Flights IN (1) OR Carrier > 'UA' ORDER BY DestState LIMIT 3
+SELECT DepDel15, DestCityName, UniqueCarrier FROM mytable WHERE ArrDel15 BETWEEN 1 AND -9999 ORDER BY DistanceGroup, AirTime LIMIT 14
+SELECT DepDel15, DivAirportIDs FROM mytable WHERE OriginCityMarketID > 32012 AND ArrDelayMinutes BETWEEN 161.0 AND 205.0 AND FlightDate = '2014-04-05' ORDER BY ActualElapsedTime, DestState, CRSArrTime LIMIT 4
+SELECT DepDel15, DivAirportLandings FROM mytable WHERE ActualElapsedTime BETWEEN 54 AND 263 AND DivAirportIDs = 11278 ORDER BY TotalAddGTime LIMIT 19
+SELECT DepDel15, OriginStateFips, Distance FROM mytable WHERE  REGEXP_LIKE(DestState, 'D.*') OR DivTailNums BETWEEN 'N585AA' AND 'N905MQ' ORDER BY Dest, DestStateFips, DestAirportID LIMIT 25
+SELECT DepDel15, OriginWac, DivReachedDest FROM mytable LIMIT 2
+SELECT DepDelay FROM mytable WHERE  REGEXP_LIKE(Origin, '.*AE') OR TaxiOut = 147 AND TotalAddGTime BETWEEN 84 AND 63 ORDER BY TailNum, DestCityName LIMIT 16
+SELECT DepDelay FROM mytable WHERE DayofMonth NOT IN (14) ORDER BY Dest LIMIT 0
+SELECT DepDelay FROM mytable WHERE TaxiIn = 48 OR DivAirports BETWEEN 'PPG' AND 'MOB' LIMIT 19
+SELECT DepDelay, CRSArrTime FROM mytable WHERE DepTime > 2212 ORDER BY TaxiOut, LateAircraftDelay, CRSArrTime LIMIT 19
+SELECT DepDelay, Cancelled, DayofMonth FROM mytable ORDER BY TotalAddGTime LIMIT 17
+SELECT DepDelay, Cancelled, DivWheelsOffs FROM mytable WHERE DivLongestGTimes BETWEEN 43.0 AND 56.0 ORDER BY DistanceGroup, WeatherDelay LIMIT 26
+SELECT DepDelay, DayofMonth FROM mytable WHERE UniqueCarrier = 'FL' OR Year BETWEEN 2014 AND 2014 OR DestState BETWEEN 'GA' AND 'IA' ORDER BY DayOfWeek LIMIT 2
+SELECT DepDelay, DivReachedDest FROM mytable WHERE DivReachedDest BETWEEN 1 AND 1 ORDER BY OriginState LIMIT 9
+SELECT DepDelay, DivTotalGTimes FROM mytable WHERE DivTotalGTimes IN (52) OR DepTime NOT IN (2220, 2344, 1407, 55, 625) LIMIT 9
+SELECT DepDelay, OriginCityName, ArrTimeBlk FROM mytable WHERE DivWheelsOns BETWEEN 1145 AND 915 LIMIT 12
+SELECT DepDelay, Quarter, SecurityDelay FROM mytable WHERE DivTailNums < 'N793SA' OR Carrier IN ('EV', 'WN', 'B6', 'VX') ORDER BY Distance, DepTime, OriginWac LIMIT 24
+SELECT DepDelayMinutes FROM mytable ORDER BY DestStateName, OriginWac, DestCityMarketID LIMIT 17
+SELECT DepDelayMinutes FROM mytable WHERE ArrTime = 1703 ORDER BY DestAirportID LIMIT 0
+SELECT DepDelayMinutes FROM mytable WHERE DivAirportIDs <= 14771 LIMIT 4
+SELECT DepDelayMinutes FROM mytable WHERE TailNum < 'N36272' AND TotalAddGTime NOT IN (42) LIMIT 5
+SELECT DepDelayMinutes, ArrDel15 FROM mytable WHERE DepartureDelayGroups NOT IN (4) AND WheelsOn = 2215 AND OriginState BETWEEN 'IN' AND 'NM' ORDER BY DepDelay, Diverted, DestCityName LIMIT 29
+SELECT DepDelayMinutes, Cancelled, DestStateName FROM mytable WHERE DivTailNums BETWEEN 'N688MQ' AND 'N554JB' AND LateAircraftDelay <= 71 AND ArrDelayMinutes BETWEEN 246.0 AND 171.0 LIMIT 21
+SELECT DepDelayMinutes, DayofMonth, TotalAddGTime FROM mytable WHERE  REGEXP_LIKE(OriginState, '.*A') AND Distance <= 262 AND DivWheelsOffs <= 1918 ORDER BY AirlineID, DepDelayMinutes, TaxiIn LIMIT 17
+SELECT DepDelayMinutes, DepDel15, OriginAirportID FROM mytable ORDER BY DepTime, DivAirportLandings LIMIT 18
+SELECT DepDelayMinutes, DepTime, DayOfWeek FROM mytable WHERE CancellationCode IN ('B') AND Distance NOT IN (842) AND ArrTime BETWEEN 1445 AND 858 ORDER BY DepDelayMinutes, DestCityName, Dest LIMIT 23
+SELECT DepDelayMinutes, Month FROM mytable WHERE DepDel15 IN (-9999) AND TaxiIn < 21 ORDER BY DepDelay, ArrTime LIMIT 16
+SELECT DepDelayMinutes, Origin, CRSDepTime FROM mytable ORDER BY DestState, Origin, WheelsOn LIMIT 28
+SELECT DepDelayMinutes, TaxiIn, OriginAirportSeqID FROM mytable WHERE Distance = 1978 OR DivReachedDest > 0 AND OriginStateFips BETWEEN 49 AND 72 ORDER BY Origin, ArrTime LIMIT 4
+SELECT DepTime FROM mytable WHERE DepTime NOT IN (752, 1559) OR SecurityDelay <> 18 ORDER BY OriginCityMarketID LIMIT 9
+SELECT DepTime FROM mytable WHERE FlightNum = 1896 ORDER BY ArrTime LIMIT 18
+SELECT DepTime FROM mytable WHERE OriginCityMarketID NOT IN (33570) LIMIT 9
+SELECT DepTime FROM mytable WHERE TaxiIn BETWEEN 14 AND 162 ORDER BY DivReachedDest, DestStateFips LIMIT 16
+SELECT DepTime, AirlineID FROM mytable WHERE CRSElapsedTime BETWEEN 390 AND 314 AND UniqueCarrier > 'HA' AND DivTailNums IN ('N378SW', 'N957DN', 'N274WN', 'N728SW', 'N16999') ORDER BY DepDel15, AirlineID, DayOfWeek LIMIT 8
+SELECT DepTime, Cancelled FROM mytable LIMIT 19
+SELECT DepTime, DestAirportSeqID, DestAirportID FROM mytable WHERE Diverted IN (1, 0) AND DivAirportIDs IN (12892, 11259, 12478) AND ArrivalDelayGroups > 9 LIMIT 7
+SELECT DepTime, DivAirportSeqIDs FROM mytable WHERE DivAirportSeqIDs <= 1482802 OR DivDistance <> 234 OR SecurityDelay BETWEEN 14 AND 27 ORDER BY OriginCityName, DestAirportSeqID LIMIT 10
+SELECT DepTimeBlk, ArrDelay, DayofMonth FROM mytable WHERE FlightNum <> 4360 LIMIT 23
+SELECT DepTimeBlk, Cancelled FROM mytable WHERE  REGEXP_LIKE(UniqueCarrier, 'U.*') AND DivAirportIDs IN (14771, 11252, 11731) LIMIT 27
+SELECT DepTimeBlk, Cancelled FROM mytable WHERE DaysSinceEpoch BETWEEN 16181 AND 16353 LIMIT 23
+SELECT DepTimeBlk, WeatherDelay FROM mytable WHERE ArrTimeBlk > '1600-1659' OR FirstDepTime > 622 ORDER BY FlightNum, OriginStateFips LIMIT 0
+SELECT DepartureDelayGroups FROM mytable ORDER BY DivArrDelay, ArrDelayMinutes, ArrivalDelayGroups LIMIT 9
+SELECT DepartureDelayGroups FROM mytable WHERE DayofMonth = 5 OR DestWac <= 35 ORDER BY DepTime LIMIT 18
+SELECT DepartureDelayGroups FROM mytable WHERE DivWheelsOns IN (1514, 1347, 2005, 1440) OR ArrDelayMinutes BETWEEN 316.0 AND 69.0 OR Quarter BETWEEN 2 AND 1 ORDER BY Diverted LIMIT 6
+SELECT DepartureDelayGroups FROM mytable WHERE FirstDepTime < 908 OR DestAirportSeqID IN (1059904) AND FlightDate BETWEEN '2014-01-13' AND '2014-01-13' ORDER BY WheelsOff LIMIT 11
+SELECT DepartureDelayGroups FROM mytable WHERE Origin = 'RDD' OR Distance BETWEEN 406 AND 711 ORDER BY DepDelay, ArrDelayMinutes, DayofMonth LIMIT 8
+SELECT DepartureDelayGroups FROM mytable WHERE OriginAirportSeqID < 1302402 AND OriginAirportSeqID IN (1302402, 1419304, 1489302) OR DestAirportID = 14730 LIMIT 7
+SELECT DepartureDelayGroups, ArrDel15 FROM mytable WHERE DestCityName BETWEEN 'Key West, FL' AND 'Twin Falls, ID' ORDER BY OriginStateFips, Distance, CRSElapsedTime LIMIT 4
+SELECT DepartureDelayGroups, Cancelled FROM mytable WHERE DayofMonth <= 29 OR TotalAddGTime NOT IN (78, 42, 4, 55, 34) OR Diverted NOT IN (1, 0) ORDER BY Flights, DestAirportID LIMIT 13
+SELECT DepartureDelayGroups, Carrier FROM mytable WHERE LongestAddGTime BETWEEN 146 AND 46 OR OriginAirportID < 11252 LIMIT 10
+SELECT DepartureDelayGroups, DaysSinceEpoch FROM mytable ORDER BY LongestAddGTime LIMIT 10
+SELECT DepartureDelayGroups, DestState, DepTimeBlk FROM mytable WHERE ArrTimeBlk BETWEEN '1400-1459' AND '0700-0759' AND Month IN (11, 12) LIMIT 22
+SELECT DepartureDelayGroups, Flights, UniqueCarrier FROM mytable ORDER BY AirTime, DaysSinceEpoch LIMIT 3
+SELECT DepartureDelayGroups, NASDelay FROM mytable WHERE DivReachedDest <> 0 OR DivAirportLandings IN (1, 0, 9) ORDER BY LateAircraftDelay, WeatherDelay LIMIT 9
+SELECT DepartureDelayGroups, TaxiIn FROM mytable WHERE TotalAddGTime = 55 ORDER BY DestAirportSeqID LIMIT 7
+SELECT DepartureDelayGroups, WheelsOn FROM mytable WHERE TailNum BETWEEN 'N243WN' AND 'N323NB' AND DivActualElapsedTime NOT IN (291) AND ArrDelayMinutes = 278.0 ORDER BY ArrDelayMinutes, Distance LIMIT 14
+SELECT Dest FROM mytable ORDER BY NASDelay, WeatherDelay, ArrDelayMinutes LIMIT 26
+SELECT Dest FROM mytable WHERE DivAirportSeqIDs IN (1091802, 1226603, 1247802) AND Diverted BETWEEN 0 AND 0 OR FlightDate NOT IN ('2014-05-03', '2014-09-22', '2014-07-30', '2014-08-08', '2014-02-20') ORDER BY DivArrDelay, ActualElapsedTime, OriginAirportID LIMIT 2
+SELECT Dest FROM mytable WHERE Year BETWEEN 2014 AND 2014 AND DestStateName < 'Missouri' ORDER BY DestCityName, NASDelay LIMIT 25
+SELECT Dest, AirTime FROM mytable WHERE ArrDelayMinutes BETWEEN 420.0 AND 351.0 OR DivDistance IN (24) OR OriginAirportID IN (10279, 11433) ORDER BY DepartureDelayGroups LIMIT 16
+SELECT Dest, ArrDel15 FROM mytable WHERE Cancelled <= 0 AND WeatherDelay >= 166 ORDER BY ArrTime
+SELECT Dest, Carrier FROM mytable WHERE DivReachedDest BETWEEN -9999 AND 1 ORDER BY DivArrDelay, CancellationCode, OriginAirportID LIMIT 29
+SELECT Dest, DayofMonth, ArrTimeBlk FROM mytable WHERE CRSDepTime <= 1607 AND WeatherDelay BETWEEN 33 AND 107 ORDER BY TaxiIn LIMIT 7
+SELECT Dest, DepDelayMinutes FROM mytable WHERE CRSElapsedTime BETWEEN 69 AND 96 OR DestAirportID BETWEEN 11003 AND 13933 OR DivWheelsOffs IN (1854) LIMIT 26
+SELECT Dest, DepDelayMinutes FROM mytable WHERE Quarter NOT IN (1, 2, 3, 4) OR DivTailNums IN ('N3FSAA', 'N796SK', 'N013AA', 'N938AT') AND DayOfWeek = 7 LIMIT 17
+SELECT Dest, DivWheelsOffs, TaxiIn FROM mytable WHERE DivAirportLandings NOT IN (0, 2) ORDER BY Year, WheelsOff, ArrDelayMinutes LIMIT 22
+SELECT Dest, Year, OriginAirportSeqID FROM mytable WHERE TaxiOut = 128 AND DivTailNums BETWEEN 'N492AA' AND 'N795AS' LIMIT 19
+SELECT DestAirportID FROM mytable ORDER BY WheelsOff, ArrDelayMinutes, DepTimeBlk LIMIT 8
+SELECT DestAirportID FROM mytable WHERE DepTime BETWEEN 1043 AND 1250 ORDER BY DivReachedDest, OriginState, OriginStateName LIMIT 17
+SELECT DestAirportID, WheelsOn FROM mytable WHERE DivAirportIDs IN (14113, 14794, 14679, 13230) AND ArrTimeBlk IN ('2000-2059', '1700-1759', '1100-1159') OR ArrTimeBlk BETWEEN '1900-1959' AND '1100-1159' ORDER BY DistanceGroup, Diverted LIMIT 22
+SELECT DestAirportSeqID FROM mytable WHERE DivReachedDest BETWEEN 1 AND -9999 OR AirTime IN (132, 259) AND Dest > 'ALB' ORDER BY DivArrDelay, DivActualElapsedTime, DepDelay LIMIT 8
+SELECT DestAirportSeqID FROM mytable WHERE Origin BETWEEN 'LBB' AND 'SGU' AND  REGEXP_LIKE(OriginState, '.*T') AND Quarter = 3 ORDER BY FlightNum, OriginStateName LIMIT 24
+SELECT DestAirportSeqID FROM mytable WHERE OriginStateFips >= 2 ORDER BY ArrTimeBlk, DepTimeBlk, UniqueCarrier LIMIT 23
+SELECT DestAirportSeqID, ArrivalDelayGroups FROM mytable WHERE TotalAddGTime IN (47, 31, 28) ORDER BY DepDel15
+SELECT DestAirportSeqID, DestAirportID FROM mytable ORDER BY OriginStateName, DepDelay LIMIT 25
+SELECT DestAirportSeqID, Distance, DivAirportSeqIDs FROM mytable WHERE Origin BETWEEN 'RST' AND 'RDM' OR Quarter = 1 ORDER BY TaxiIn, Diverted LIMIT 26
+SELECT DestAirportSeqID, DivAirportIDs, UniqueCarrier FROM mytable WHERE DestCityName = 'Albany, GA' AND DepDel15 = 0 OR DivAirportSeqIDs <= 1112202 LIMIT 9
+SELECT DestAirportSeqID, UniqueCarrier, DestCityMarketID FROM mytable WHERE OriginAirportSeqID = 1422204 AND DistanceGroup NOT IN (11, 2, 7) AND OriginCityName IN ('Kalamazoo, MI', 'Oklahoma City, OK', 'San Diego, CA', 'Grand Island, NE') ORDER BY AirlineID LIMIT 26
+SELECT DestCityMarketID FROM mytable ORDER BY DivReachedDest, OriginCityName LIMIT 29
+SELECT DestCityMarketID FROM mytable WHERE DivLongestGTimes BETWEEN 39.0 AND 156.0 ORDER BY DayofMonth LIMIT 27
+SELECT DestCityMarketID FROM mytable WHERE Year = 2014 OR  REGEXP_LIKE(OriginCityName, 'Clev.*land, OH') AND Origin = 'LFT' ORDER BY LateAircraftDelay LIMIT 12
+SELECT DestCityMarketID, OriginAirportID FROM mytable WHERE FirstDepTime <= 1119 OR OriginAirportSeqID = 1091802 OR DivAirportLandings = 9 ORDER BY ArrDel15, DestAirportSeqID, DestStateFips LIMIT 22
+SELECT DestCityMarketID, WheelsOn, Distance FROM mytable WHERE WheelsOn BETWEEN 205 AND 1422 OR WheelsOn BETWEEN 1933 AND 1456 LIMIT 8
+SELECT DestCityMarketID, WheelsOn, OriginAirportID FROM mytable WHERE ArrDelay IN (97.0) OR FlightNum > 3329 AND OriginAirportSeqID NOT IN (1087402) ORDER BY SecurityDelay, OriginState LIMIT 7
+SELECT DestCityName FROM mytable LIMIT 7
+SELECT DestCityName FROM mytable ORDER BY CRSArrTime, WheelsOn LIMIT 12
+SELECT DestCityName FROM mytable ORDER BY Dest LIMIT 14
+SELECT DestCityName FROM mytable WHERE DepartureDelayGroups BETWEEN 5 AND 6 OR DivTailNums BETWEEN 'N4WJAA' AND 'N8314L' ORDER BY Dest, DestCityMarketID LIMIT 21
+SELECT DestCityName FROM mytable WHERE DivTailNums IN ('N636JB', 'N1EAMQ', 'N219AG', 'N223AG') OR DestState BETWEEN 'ME' AND 'SC' ORDER BY TaxiOut, CRSArrTime, DestStateName LIMIT 26
+SELECT DestCityName FROM mytable WHERE NASDelay BETWEEN 80 AND 36 AND DistanceGroup = 10 ORDER BY Distance, TailNum, Origin LIMIT 5
+SELECT DestCityName, ArrDel15, DivArrDelay FROM mytable WHERE AirlineID NOT IN (20304, 19790, 19805) AND FlightDate = '2014-01-09' ORDER BY ArrTime, NASDelay, AirlineID LIMIT 0
+SELECT DestCityName, DayOfWeek FROM mytable WHERE OriginAirportID BETWEEN 14696 AND 14633 AND UniqueCarrier = 'VX' ORDER BY DepTime, OriginAirportID LIMIT 6
+SELECT DestCityName, Dest FROM mytable WHERE FlightDate <= '2014-01-10' OR DivTailNums IN ('N630JB', 'N130DL', 'N371SW') AND DivWheelsOffs IN (1715) ORDER BY DestStateFips, ArrDelayMinutes LIMIT 29
+SELECT DestCityName, DivTotalGTimes FROM mytable WHERE Origin = 'EUG' AND UniqueCarrier NOT IN ('HA', 'AS', 'AA') OR DestWac NOT IN (51, 54, 37) ORDER BY FlightNum, DestCityName, DestAirportID LIMIT 24
+SELECT DestCityName, NASDelay FROM mytable LIMIT 12
+SELECT DestCityName, OriginAirportID FROM mytable WHERE WheelsOff = 1619 OR LongestAddGTime BETWEEN -9999 AND 86 ORDER BY FirstDepTime LIMIT 8
+SELECT DestCityName, WheelsOn FROM mytable WHERE SecurityDelay >= 1 OR DepDel15 BETWEEN -9999 AND -9999 ORDER BY CarrierDelay, ArrDel15, DestStateName LIMIT 22
+SELECT DestState FROM mytable LIMIT 23
+SELECT DestState FROM mytable ORDER BY ArrTime LIMIT 17
+SELECT DestState FROM mytable ORDER BY DestAirportSeqID LIMIT 17
+SELECT DestState FROM mytable WHERE DestWac >= 22 OR NASDelay NOT IN (1, 19) ORDER BY DepDelay, DivAirportLandings, OriginStateName LIMIT 10
+SELECT DestState FROM mytable WHERE DivLongestGTimes > 145.0 ORDER BY DepDelay, WeatherDelay LIMIT 6
+SELECT DestState, ArrDel15 FROM mytable WHERE DivDistance BETWEEN 251 AND 0 OR DepTime > 1157 ORDER BY FlightNum, TaxiIn LIMIT 15
+SELECT DestState, ArrDelay, DaysSinceEpoch FROM mytable WHERE OriginState BETWEEN 'NE' AND 'NY' OR ArrDel15 BETWEEN -9999 AND 1 LIMIT 29
+SELECT DestState, ArrTimeBlk FROM mytable WHERE Distance <= 1162 OR DepDelay NOT IN (52.0, 88.0, 77.0, 66.0, -11.0) AND Dest >= 'MCI' ORDER BY DepDelay, OriginState LIMIT 9
+SELECT DestState, CRSArrTime FROM mytable WHERE OriginStateName > 'U.S. Virgin Islands' AND OriginCityMarketID = 30198 OR Distance BETWEEN 840 AND 1609 ORDER BY DivActualElapsedTime, OriginStateFips LIMIT 25
+SELECT DestState, CRSDepTime, DivActualElapsedTime FROM mytable ORDER BY DepDelayMinutes, AirTime LIMIT 26
+SELECT DestState, Cancelled, TailNum FROM mytable WHERE ArrTimeBlk IN ('1000-1059', '2100-2159', '0600-0659', '1200-1259', '1800-1859') OR OriginAirportSeqID BETWEEN 1186502 AND 1131502 ORDER BY ArrTime LIMIT 10
+SELECT DestState, Distance, OriginCityName FROM mytable WHERE Month <= 1 ORDER BY DepTime, DestStateName LIMIT 22
+SELECT DestState, OriginAirportID FROM mytable WHERE OriginAirportID NOT IN (15356, 10136) LIMIT 2
+SELECT DestState, OriginAirportSeqID, DaysSinceEpoch FROM mytable ORDER BY LongestAddGTime LIMIT 5
+SELECT DestState, WeatherDelay FROM mytable WHERE Flights BETWEEN 1 AND 1 AND DayOfWeek >= 4 OR Carrier BETWEEN 'F9' AND 'WN' ORDER BY FlightNum, OriginCityName, ArrTime LIMIT 28
+SELECT DestState, WheelsOn FROM mytable WHERE TaxiIn = 69 AND FlightNum BETWEEN 7392 AND 2938 ORDER BY DestCityMarketID LIMIT 28
+SELECT DestStateFips FROM mytable WHERE ArrivalDelayGroups = -2 ORDER BY ArrDel15 LIMIT 18
+SELECT DestStateFips FROM mytable WHERE DepTime BETWEEN 1321 AND 1115 AND OriginStateFips BETWEEN 13 AND 44 OR FlightDate >= '2014-01-06' ORDER BY DistanceGroup LIMIT 5
+SELECT DestStateFips, AirlineID FROM mytable WHERE DivWheelsOffs IN (5, 1403) ORDER BY Month LIMIT 9
+SELECT DestStateFips, ArrDel15 FROM mytable ORDER BY DepDelay, TotalAddGTime, DestStateName LIMIT 5
+SELECT DestStateFips, ArrDelayMinutes FROM mytable WHERE AirTime BETWEEN 394 AND 367 AND Quarter BETWEEN 4 AND 1 ORDER BY OriginStateName, CancellationCode, OriginCityName LIMIT 4
+SELECT DestStateFips, ArrTimeBlk, UniqueCarrier FROM mytable ORDER BY OriginCityMarketID, ActualElapsedTime, Month LIMIT 3
+SELECT DestStateFips, ArrivalDelayGroups FROM mytable ORDER BY DayOfWeek, DivActualElapsedTime, OriginAirportID LIMIT 21
+SELECT DestStateFips, ArrivalDelayGroups FROM mytable WHERE OriginAirportSeqID BETWEEN 1357702 AND 1153703 ORDER BY Month LIMIT 5
+SELECT DestStateFips, DaysSinceEpoch FROM mytable WHERE FirstDepTime = 1902 ORDER BY WheelsOff, DestCityName LIMIT 9
+SELECT DestStateFips, DivTailNums, DayofMonth FROM mytable WHERE CRSArrTime BETWEEN 809 AND 1655 AND LateAircraftDelay <= 154 ORDER BY DestAirportID, DestCityMarketID LIMIT 12
+SELECT DestStateName FROM mytable LIMIT 8
+SELECT DestStateName FROM mytable ORDER BY DepDelayMinutes LIMIT 27
+SELECT DestStateName FROM mytable WHERE  REGEXP_LIKE(OriginState, '.*C') AND DepartureDelayGroups > 1 ORDER BY Dest, TaxiOut LIMIT 16
+SELECT DestStateName FROM mytable WHERE ActualElapsedTime > 163 AND DivAirportLandings <> 2 ORDER BY ArrDelay, DayofMonth, OriginAirportID LIMIT 1
+SELECT DestStateName FROM mytable WHERE DayOfWeek >= 1 LIMIT 15
+SELECT DestStateName FROM mytable WHERE DestCityMarketID > 33195 AND ArrDel15 <> 1 LIMIT 11
+SELECT DestStateName FROM mytable WHERE OriginAirportSeqID BETWEEN 1275803 AND 1129803 OR ArrDel15 BETWEEN -9999 AND 0 OR ArrDel15 >= -9999 ORDER BY Quarter, FlightNum, DestAirportSeqID LIMIT 23
+SELECT DestStateName, AirlineID, DivActualElapsedTime FROM mytable LIMIT 15
+SELECT DestStateName, DivAirportIDs, WheelsOn FROM mytable ORDER BY ArrTimeBlk LIMIT 22
+SELECT DestStateName, NASDelay FROM mytable WHERE OriginCityName BETWEEN 'Roanoke, VA' AND 'Lewiston, ID' AND Quarter NOT IN (1) AND Carrier > 'FL' ORDER BY DivReachedDest, ArrivalDelayGroups LIMIT 23
+SELECT DestStateName, NASDelay, ArrDelay FROM mytable ORDER BY AirTime LIMIT 17
+SELECT DestStateName, NASDelay, CancellationCode FROM mytable WHERE DestCityMarketID NOT IN (30918, 31865, 33964, 34543, 33277) AND DivWheelsOns BETWEEN 1017 AND 1018 OR TailNum IN ('N3733Z', 'N919DE', 'N658CT', 'N12567') ORDER BY DayofMonth LIMIT 7
+SELECT DestWac FROM mytable LIMIT 3
+SELECT DestWac FROM mytable WHERE DestCityMarketID IN (32884, 33024, 33792, 31041) AND DepDelayMinutes > 536.0 LIMIT 14
+SELECT DestWac FROM mytable WHERE DestState BETWEEN 'TX' AND 'PA' LIMIT 21
+SELECT DestWac FROM mytable WHERE DivReachedDest >= 1 OR ArrTime NOT IN (816) OR DepTime NOT IN (853, 1430) ORDER BY DivActualElapsedTime, Cancelled LIMIT 24
+SELECT DestWac FROM mytable WHERE Flights = 1 OR Origin NOT IN ('KTN', 'DTW') AND FirstDepTime = 1046 ORDER BY Month, OriginAirportSeqID, DaysSinceEpoch LIMIT 9
+SELECT DestWac, ArrDel15, CRSDepTime FROM mytable ORDER BY DepDelay LIMIT 22
+SELECT DestWac, CRSDepTime, DivActualElapsedTime FROM mytable WHERE TaxiIn NOT IN (64, 15) ORDER BY DestWac, OriginState LIMIT 21
+SELECT DestWac, DepDel15, OriginWac FROM mytable WHERE WheelsOn = 1351 AND OriginCityMarketID BETWEEN 34952 AND 30466 LIMIT 27
+SELECT DestWac, DepDelay FROM mytable WHERE OriginAirportID BETWEEN 10372 AND 14730 AND DivAirportSeqIDs BETWEEN 1524903 AND 1348502 OR OriginStateFips BETWEEN 10 AND 45 ORDER BY TaxiOut, Diverted, ArrivalDelayGroups LIMIT 7
+SELECT DestWac, DepDelay, Dest FROM mytable WHERE WheelsOff >= 2011 AND DepTimeBlk IN ('1200-1259', '1400-1459', '1500-1559') LIMIT 24
+SELECT DestWac, DestStateName FROM mytable WHERE AirlineID BETWEEN 19930 AND 20437 AND DepartureDelayGroups < -1 OR Month NOT IN (1) ORDER BY Quarter, LateAircraftDelay, OriginCityName LIMIT 0
+SELECT DestWac, DivWheelsOffs, OriginWac FROM mytable WHERE DivLongestGTimes IN (102.0, 21.0, 42.0, 62.0) ORDER BY Flights, DepTimeBlk, AirlineID LIMIT 13
+SELECT DestWac, FirstDepTime FROM mytable WHERE ArrTime BETWEEN 1221 AND 6 AND LongestAddGTime < 39 ORDER BY Diverted LIMIT 0
+SELECT DestWac, OriginStateFips, DivTailNums FROM mytable WHERE AirlineID NOT IN (20436, 20366, 20409) AND DivLongestGTimes IN (3.0, 85.0, 38.0, 75.0) AND Year <> 2014 ORDER BY Month LIMIT 10
+SELECT DestWac, OriginWac, WheelsOn FROM mytable WHERE DivActualElapsedTime BETWEEN 318 AND 280 ORDER BY OriginState, OriginStateFips LIMIT 5
+SELECT DestWac, TotalAddGTime FROM mytable WHERE DivWheelsOns < 2334 ORDER BY DestState, Quarter, DestAirportSeqID LIMIT 19
+SELECT Distance FROM mytable WHERE DivDistance >= 109 OR DivWheelsOns BETWEEN 1628 AND 1554 LIMIT 23
+SELECT Distance, DivAirportLandings, OriginWac FROM mytable ORDER BY DaysSinceEpoch LIMIT 20
+SELECT Distance, DivWheelsOffs FROM mytable WHERE DestState BETWEEN 'NY' AND 'IA' AND TailNum BETWEEN 'N764SK' AND 'N15985' AND Month <> 1 LIMIT 3
+SELECT Distance, Month FROM mytable WHERE CRSDepTime = 1037 AND DivAirports IN ('MCN') ORDER BY Year, Distance, SecurityDelay LIMIT 11
+SELECT Distance, WheelsOn FROM mytable WHERE OriginStateFips BETWEEN 28 AND 33 AND NASDelay NOT IN (2, 106) ORDER BY DestCityMarketID LIMIT 5
+SELECT DistanceGroup FROM mytable ORDER BY FlightNum, ArrTime, DayOfWeek LIMIT 12
+SELECT DistanceGroup FROM mytable WHERE DestAirportSeqID BETWEEN 1463502 AND 1338801 LIMIT 24
+SELECT DistanceGroup FROM mytable WHERE DistanceGroup IN (2) AND ArrDelayMinutes < 341.0 OR Diverted = 0 ORDER BY Flights, TailNum LIMIT 23
+SELECT DistanceGroup FROM mytable WHERE WeatherDelay <= 101 OR Month >= 1 AND AirTime BETWEEN 85 AND 442 ORDER BY DepDelayMinutes, ArrTime, Dest LIMIT 13
+SELECT DistanceGroup, AirlineID FROM mytable ORDER BY TaxiOut, Year, DivAirportLandings LIMIT 11
+SELECT DistanceGroup, ArrTimeBlk, UniqueCarrier FROM mytable ORDER BY CRSArrTime, OriginAirportID LIMIT 21
+SELECT DistanceGroup, CRSElapsedTime, DestCityMarketID FROM mytable ORDER BY AirTime, DepTimeBlk, ArrTimeBlk LIMIT 27
+SELECT DistanceGroup, CarrierDelay, DestCityName FROM mytable WHERE Month NOT IN (1) ORDER BY DestWac LIMIT 2
+SELECT DistanceGroup, DestAirportID FROM mytable ORDER BY DepDelayMinutes, DaysSinceEpoch LIMIT 19
+SELECT DistanceGroup, DestCityMarketID FROM mytable WHERE CancellationCode NOT IN ('noodles', 'C', 'B') AND DivArrDelay NOT IN (765) AND DivActualElapsedTime = 327 LIMIT 16
+SELECT DistanceGroup, DestStateFips, OriginAirportID FROM mytable WHERE DivWheelsOffs BETWEEN 202 AND 1314 AND DestState NOT IN ('KY', 'NE') ORDER BY NASDelay, DaysSinceEpoch LIMIT 16
+SELECT DistanceGroup, TotalAddGTime FROM mytable WHERE OriginStateName IN ('Mississippi', 'Georgia') OR DivWheelsOffs <= 1906 LIMIT 15
+SELECT DivActualElapsedTime FROM mytable ORDER BY ArrTimeBlk LIMIT 27
+SELECT DivActualElapsedTime FROM mytable WHERE CRSDepTime BETWEEN 500 AND 646 OR DivTotalGTimes > 180 LIMIT 20
+SELECT DivActualElapsedTime FROM mytable WHERE Cancelled IN (1, 0) ORDER BY Diverted LIMIT 19
+SELECT DivActualElapsedTime FROM mytable WHERE DepDel15 < 0 ORDER BY FlightNum LIMIT 15
+SELECT DivActualElapsedTime FROM mytable WHERE DestCityMarketID BETWEEN 33244 AND 32337 OR WheelsOff = 1248 OR DivReachedDest = -9999 ORDER BY FlightDate, CancellationCode, DaysSinceEpoch LIMIT 24
+SELECT DivActualElapsedTime FROM mytable WHERE DistanceGroup BETWEEN 4 AND 1 OR DepDelay <> 124.0 ORDER BY OriginStateName LIMIT 7
+SELECT DivActualElapsedTime, ArrDel15, DivAirportIDs FROM mytable LIMIT 19
+SELECT DivActualElapsedTime, DivWheelsOffs, DestStateName FROM mytable WHERE DestCityName < 'Dothan, AL' AND AirTime = 315 AND Carrier >= 'OO' LIMIT 26
+SELECT DivActualElapsedTime, LongestAddGTime, CRSArrTime FROM mytable WHERE DivAirportIDs <= 11618 OR AirTime BETWEEN 134 AND 406 AND AirlineID < 21171 ORDER BY DistanceGroup, DestCityMarketID LIMIT 21
+SELECT DivAirportIDs FROM mytable WHERE AirTime NOT IN (115, 11, 100, 351) ORDER BY Quarter, TailNum LIMIT 4
+SELECT DivAirportIDs FROM mytable WHERE DestCityMarketID <= 30113 AND WheelsOff IN (1921, 1257, 1332) ORDER BY Carrier LIMIT 25
+SELECT DivAirportIDs FROM mytable WHERE Quarter NOT IN (1) AND AirTime IN (312, 273) OR DestState BETWEEN 'PR' AND 'LA' LIMIT 10
+SELECT DivAirportIDs, DestCityName, OriginAirportID FROM mytable WHERE OriginCityName BETWEEN 'San Antonio, TX' AND 'Omaha, NE' OR CarrierDelay <> 169 ORDER BY ArrDelay LIMIT 14
+SELECT DivAirportLandings FROM mytable ORDER BY Flights LIMIT 9
+SELECT DivAirportLandings FROM mytable WHERE ActualElapsedTime NOT IN (180, 145, 415, 177, 347) AND FlightDate BETWEEN '2014-01-06' AND '2014-01-24' OR OriginWac BETWEEN 91 AND 41 LIMIT 9
+SELECT DivAirportLandings FROM mytable WHERE CarrierDelay BETWEEN 23 AND 43 AND DivReachedDest BETWEEN -9999 AND 0 LIMIT 17
+SELECT DivAirportLandings FROM mytable WHERE DestWac BETWEEN 12 AND 85 ORDER BY DepTimeBlk
+SELECT DivAirportLandings, DaysSinceEpoch FROM mytable ORDER BY Quarter LIMIT 27
+SELECT DivAirportLandings, DaysSinceEpoch FROM mytable WHERE ActualElapsedTime NOT IN (544, 335) ORDER BY CarrierDelay, ArrTime, OriginAirportID LIMIT 21
+SELECT DivAirportLandings, DepDelay FROM mytable WHERE DestCityMarketID <= 32519 OR WheelsOff IN (1655, 506, 1900) AND Cancelled >= 0 ORDER BY DepDel15 LIMIT 2
+SELECT DivAirportLandings, DestCityMarketID, Distance FROM mytable ORDER BY SecurityDelay, OriginCityName LIMIT 24
+SELECT DivAirportLandings, Year, ArrDelay FROM mytable WHERE NASDelay = 92 ORDER BY Carrier LIMIT 19
+SELECT DivAirportSeqIDs FROM mytable ORDER BY NASDelay LIMIT 23
+SELECT DivAirportSeqIDs FROM mytable WHERE DepDelay IN (63.0, 270.0, 408.0) OR OriginCityMarketID = 34794 ORDER BY DivDistance, OriginAirportSeqID, DestAirportID LIMIT 23
+SELECT DivAirportSeqIDs FROM mytable WHERE DivDistance = 128 ORDER BY CRSDepTime, DayOfWeek LIMIT 14
+SELECT DivAirportSeqIDs, DestStateName FROM mytable ORDER BY CarrierDelay, ArrDelayMinutes, DestStateName LIMIT 9
+SELECT DivAirports FROM mytable ORDER BY DestAirportSeqID LIMIT 17
+SELECT DivAirports FROM mytable ORDER BY Quarter LIMIT 26
+SELECT DivAirports FROM mytable WHERE DestStateFips > 17 ORDER BY Distance, ArrDelay, OriginAirportID LIMIT 8
+SELECT DivAirports FROM mytable WHERE UniqueCarrier BETWEEN 'DL' AND 'FL' OR DivReachedDest NOT IN (1, -9999) OR DestAirportID < 11726 ORDER BY ArrDel15 LIMIT 4
+SELECT DivAirports, CancellationCode, DestAirportID FROM mytable WHERE OriginWac > 92 OR DepTimeBlk NOT IN ('1900-1959', '2300-2359', '0800-0859', '1700-1759', '2200-2259') OR  REGEXP_LIKE(FlightDate, '2014-03.*07') ORDER BY OriginCityMarketID, WheelsOn LIMIT 11
+SELECT DivAirports, DepDelayMinutes FROM mytable WHERE NASDelay BETWEEN 23 AND 139 AND DepartureDelayGroups NOT IN (12, 6, -9999, 9, 10) LIMIT 14
+SELECT DivAirports, DistanceGroup, DestAirportID FROM mytable WHERE Diverted NOT IN (0, 1) AND DestCityMarketID NOT IN (30154, 30918, 33485, 31986) ORDER BY ArrDel15 LIMIT 13
+SELECT DivAirports, FirstDepTime, TailNum FROM mytable WHERE  REGEXP_LIKE(OriginState, '.*E') AND ArrivalDelayGroups BETWEEN -2 AND 11 AND DepDel15 > -9999 ORDER BY CarrierDelay, DepTime LIMIT 4
+SELECT DivAirports, OriginAirportSeqID FROM mytable WHERE ActualElapsedTime BETWEEN 445 AND 294 AND DivWheelsOffs <= 914 LIMIT 17
+SELECT DivAirports, OriginCityName FROM mytable WHERE DestStateFips > 25 OR FlightDate = '2014-01-22' ORDER BY OriginStateFips, DivDistance LIMIT 7
+SELECT DivAirports, TaxiIn, DivAirportLandings FROM mytable ORDER BY CRSArrTime, CRSDepTime, DaysSinceEpoch
+SELECT DivAirports, WeatherDelay, Distance FROM mytable WHERE DestWac BETWEEN 74 AND 34 ORDER BY Dest, DaysSinceEpoch LIMIT 1
+SELECT DivArrDelay FROM mytable ORDER BY DayOfWeek, OriginWac LIMIT 18
+SELECT DivArrDelay FROM mytable ORDER BY DepDel15, Dest LIMIT 9
+SELECT DivArrDelay FROM mytable ORDER BY LongestAddGTime, DepDelay, DestState LIMIT 29
+SELECT DivArrDelay FROM mytable WHERE ActualElapsedTime = 399 ORDER BY DivDistance, OriginWac, OriginStateFips LIMIT 8
+SELECT DivArrDelay FROM mytable WHERE DaysSinceEpoch BETWEEN 16244 AND 16175 AND DestStateFips = 15 ORDER BY DepDel15 LIMIT 5
+SELECT DivArrDelay FROM mytable WHERE DistanceGroup IN (4, 7, 9) OR Dest > 'MDT' ORDER BY DepDel15 LIMIT 3
+SELECT DivArrDelay FROM mytable WHERE DivWheelsOffs IN (956) OR DestAirportID NOT IN (12519, 14831, 15841) LIMIT 26
+SELECT DivArrDelay FROM mytable WHERE Flights BETWEEN 1 AND 1 ORDER BY DivReachedDest, DestStateFips, ActualElapsedTime LIMIT 11
+SELECT DivArrDelay FROM mytable WHERE TaxiOut > 138 OR ArrTimeBlk NOT IN ('2000-2059', '0600-0659', '0800-0859', '2200-2259') OR Quarter NOT IN (3) ORDER BY ArrDelay LIMIT 25
+SELECT DivArrDelay, ArrDelay FROM mytable WHERE AirTime = 200 AND DestAirportID = 10136 OR CRSArrTime = 1855 ORDER BY Quarter, OriginWac, AirTime LIMIT 29
+SELECT DivArrDelay, CRSElapsedTime, ArrTimeBlk FROM mytable WHERE DestAirportSeqID BETWEEN 1069302 AND 1190502 OR DayofMonth = 10 OR AirlineID >= 19790 LIMIT 21
+SELECT DivArrDelay, DestWac, DestAirportID FROM mytable WHERE OriginWac <= 2 OR  REGEXP_LIKE(ArrTimeBlk, '1.*00-1359') AND NASDelay > 213 ORDER BY DepartureDelayGroups, OriginAirportSeqID LIMIT 23
+SELECT DivArrDelay, DivActualElapsedTime, ArrTime FROM mytable ORDER BY WheelsOff LIMIT 14
+SELECT DivArrDelay, FlightDate, DayofMonth FROM mytable WHERE FlightNum BETWEEN 512 AND 3535 AND WeatherDelay BETWEEN 88 AND 973 ORDER BY ArrDelayMinutes LIMIT 14
+SELECT DivArrDelay, OriginStateName, DivAirports FROM mytable WHERE OriginAirportSeqID BETWEEN 1387302 AND 1509602 OR Distance = 1532 OR DivWheelsOns IN (1139, 1424, 1401, 1135, 2020) LIMIT 4
+SELECT DivDistance FROM mytable ORDER BY DistanceGroup, CarrierDelay, DepTime LIMIT 26
+SELECT DivDistance FROM mytable WHERE  REGEXP_LIKE(CancellationCode, '.*') LIMIT 15
+SELECT DivDistance FROM mytable WHERE CancellationCode <= 'C' AND Origin BETWEEN 'HOU' AND 'SBA' AND ActualElapsedTime = 130 ORDER BY DayofMonth LIMIT 3
+SELECT DivDistance, ArrTimeBlk FROM mytable WHERE ActualElapsedTime NOT IN (301, 668, 294) OR WeatherDelay = 61 ORDER BY OriginWac, OriginStateFips, ArrivalDelayGroups LIMIT 0
+SELECT DivDistance, CarrierDelay FROM mytable WHERE DestStateFips <= 31 AND DivTailNums BETWEEN 'N8315C' AND 'N4XLAA' ORDER BY SecurityDelay, DivAirportLandings LIMIT 2
+SELECT DivDistance, DepTime FROM mytable ORDER BY FlightNum, Diverted LIMIT 12
+SELECT DivDistance, Dest FROM mytable WHERE DestCityName IN ('Wichita, KS') OR LateAircraftDelay NOT IN (159) AND DestAirportSeqID NOT IN (1468902) ORDER BY WheelsOff, Distance LIMIT 14
+SELECT DivDistance, DestAirportSeqID, TailNum FROM mytable WHERE DestState NOT IN ('CA', 'IA', 'AR') LIMIT 18
+SELECT DivDistance, DestStateFips, TotalAddGTime FROM mytable WHERE LateAircraftDelay IN (127) AND DivReachedDest NOT IN (1, 0, -9999) AND CancellationCode BETWEEN 'noodles' AND 'noodles' LIMIT 17
+SELECT DivDistance, Distance, DepTime FROM mytable WHERE  REGEXP_LIKE(DepTimeBlk, '0800-085.*') AND DivLongestGTimes IN (149.0, 22.0, 124.0) OR AirlineID BETWEEN 20355 AND 20366 ORDER BY DistanceGroup, DestWac, DestCityName LIMIT 19
+SELECT DivDistance, DivAirportSeqIDs FROM mytable ORDER BY DepartureDelayGroups, OriginState LIMIT 6
+SELECT DivDistance, Diverted FROM mytable ORDER BY FlightDate, DivReachedDest, DayofMonth LIMIT 23
+SELECT DivDistance, NASDelay, OriginWac FROM mytable WHERE ArrTimeBlk >= '1400-1459' AND ArrDel15 IN (1, 0) ORDER BY OriginStateFips LIMIT 24
+SELECT DivLongestGTimes FROM mytable ORDER BY SecurityDelay, ArrDelayMinutes LIMIT 21
+SELECT DivLongestGTimes, ArrTimeBlk, DestCityName FROM mytable WHERE DivAirportIDs <= 13024 OR Quarter BETWEEN 1 AND 1 AND DestAirportSeqID NOT IN (1393303, 1164802) ORDER BY OriginState, TaxiIn, Month LIMIT 0
+SELECT DivLongestGTimes, DayofMonth FROM mytable WHERE DestCityName BETWEEN 'Hilo, HI' AND 'Boston, MA' AND CarrierDelay BETWEEN 17 AND 141 OR ArrDelayMinutes = 93.0 ORDER BY OriginStateFips, Flights LIMIT 0
+SELECT DivLongestGTimes, DepDelay FROM mytable WHERE FlightDate NOT IN ('2014-01-06', '2014-11-29') ORDER BY ActualElapsedTime, FlightDate LIMIT 17
+SELECT DivLongestGTimes, Distance, CancellationCode FROM mytable WHERE OriginAirportSeqID BETWEEN 1445702 AND 1484304 OR TaxiIn BETWEEN 8 AND 30 AND Cancelled IN (1, 0) ORDER BY DistanceGroup, LateAircraftDelay, NASDelay LIMIT 2
+SELECT DivLongestGTimes, DistanceGroup FROM mytable WHERE DestState = 'NV' LIMIT 14
+SELECT DivLongestGTimes, Flights FROM mytable WHERE DestCityMarketID BETWEEN 34524 AND 30155 ORDER BY DivActualElapsedTime LIMIT 27
+SELECT DivLongestGTimes, OriginAirportSeqID FROM mytable WHERE DivAirports IN ('MDY', 'RNO', 'DRO', 'ATW') OR DestStateFips BETWEEN 13 AND 28 ORDER BY CancellationCode, OriginWac LIMIT 0
+SELECT DivLongestGTimes, TotalAddGTime FROM mytable WHERE WeatherDelay <> 9 AND DivDistance = 417 OR DestStateFips BETWEEN 19 AND 5 LIMIT 0
+SELECT DivReachedDest FROM mytable ORDER BY DistanceGroup, OriginStateFips, WeatherDelay LIMIT 17
+SELECT DivReachedDest FROM mytable WHERE ArrivalDelayGroups BETWEEN -1 AND 5 ORDER BY TailNum LIMIT 20
+SELECT DivReachedDest FROM mytable WHERE DivReachedDest = -9999 ORDER BY OriginCityMarketID, Diverted LIMIT 3
+SELECT DivReachedDest FROM mytable WHERE SecurityDelay NOT IN (1, 0, 4, 27, -9999) OR DivArrDelay = 322 ORDER BY Origin, CRSDepTime LIMIT 7
+SELECT DivReachedDest, ArrDelayMinutes FROM mytable WHERE DivTotalGTimes BETWEEN 164 AND 138 LIMIT 20
+SELECT DivReachedDest, CarrierDelay, WheelsOn FROM mytable ORDER BY OriginCityMarketID, OriginCityName, DaysSinceEpoch LIMIT 20
+SELECT DivReachedDest, DayofMonth FROM mytable WHERE TotalAddGTime BETWEEN 19 AND 40 AND Diverted BETWEEN 1 AND 1 AND DayOfWeek BETWEEN 3 AND 7 LIMIT 10
+SELECT DivReachedDest, DepDelay, Dest FROM mytable WHERE ArrDelay <> 363.0 OR WheelsOff BETWEEN 1836 AND 905 OR DivReachedDest BETWEEN 1 AND 1 ORDER BY DayofMonth LIMIT 11
+SELECT DivReachedDest, DestWac, DivActualElapsedTime FROM mytable WHERE DepTimeBlk IN ('2200-2259', '0700-0759', '0800-0859', '1400-1459', '1800-1859') OR CRSElapsedTime >= 196 OR AirTime BETWEEN 163 AND 251 ORDER BY WheelsOn, ArrivalDelayGroups LIMIT 7
+SELECT DivReachedDest, Diverted, OriginAirportID FROM mytable WHERE DivTailNums >= 'N675MQ' OR DestState BETWEEN 'VI' AND 'VT' AND DepDelayMinutes BETWEEN 82.0 AND 487.0 LIMIT 18
+SELECT DivReachedDest, FlightDate, Origin FROM mytable WHERE ActualElapsedTime BETWEEN 310 AND 423 OR CRSDepTime NOT IN (1454, 1248, 1737, 1036) AND TailNum BETWEEN 'N37267' AND 'N104UW' ORDER BY CRSArrTime, Month LIMIT 23
+SELECT DivReachedDest, FlightNum, DepDelayMinutes FROM mytable WHERE SecurityDelay BETWEEN 8 AND 0 ORDER BY Dest, ArrDelay LIMIT 14
+SELECT DivReachedDest, NASDelay FROM mytable WHERE CRSElapsedTime = 255 LIMIT 29
+SELECT DivReachedDest, TailNum FROM mytable WHERE DivTotalGTimes BETWEEN 32 AND 90 AND WheelsOn NOT IN (2017, 812, 1521, 1541, 928) AND DivAirports BETWEEN 'LAS' AND 'SYR' ORDER BY DepTime LIMIT 29
+SELECT DivTailNums FROM mytable ORDER BY NASDelay LIMIT 13
+SELECT DivTailNums FROM mytable WHERE AirTime NOT IN (276, 11) OR CarrierDelay NOT IN (201) LIMIT 29
+SELECT DivTailNums, Month, CRSElapsedTime FROM mytable LIMIT 21
+SELECT DivTailNums, TailNum, DestCityName FROM mytable WHERE LongestAddGTime BETWEEN 24 AND 69 OR Month IN (12, 5) AND DepDel15 = -9999 ORDER BY DivArrDelay, ArrDelayMinutes LIMIT 2
+SELECT DivTotalGTimes FROM mytable LIMIT 5
+SELECT DivTotalGTimes FROM mytable WHERE ArrDelay BETWEEN 349.0 AND 323.0 OR DivWheelsOffs IN (919, 951, 1705) ORDER BY Year LIMIT 6
+SELECT DivTotalGTimes FROM mytable WHERE ArrTimeBlk NOT IN ('1200-1259') ORDER BY DayOfWeek, DestState, UniqueCarrier LIMIT 16
+SELECT DivTotalGTimes FROM mytable WHERE DestAirportID >= 13486 OR DivActualElapsedTime BETWEEN 174 AND 207 AND LateAircraftDelay BETWEEN 109 AND 85 ORDER BY DivDistance, TailNum, UniqueCarrier LIMIT 27
+SELECT DivTotalGTimes FROM mytable WHERE DivActualElapsedTime BETWEEN 214 AND 461 OR DivDistance BETWEEN 1262 AND 449 AND CRSArrTime BETWEEN 2102 AND 2221 ORDER BY DepTime, DestCityName, AirlineID LIMIT 16
+SELECT DivTotalGTimes FROM mytable WHERE DivArrDelay NOT IN (1280, 42, 331) OR DepDel15 NOT IN (1, 0, -9999) AND DepDel15 > 0 LIMIT 23
+SELECT DivTotalGTimes FROM mytable WHERE TailNum NOT IN ('N8612K', 'N918MQ', 'N954WN') OR Quarter BETWEEN 1 AND 1 ORDER BY Dest, DepTimeBlk LIMIT 15
+SELECT DivTotalGTimes, DestAirportSeqID, TotalAddGTime FROM mytable WHERE CarrierDelay > 148 ORDER BY DivDistance, WheelsOff, TotalAddGTime LIMIT 18
+SELECT DivTotalGTimes, DestCityMarketID, DivAirportIDs FROM mytable WHERE UniqueCarrier >= 'WN' LIMIT 15
+SELECT DivWheelsOffs FROM mytable ORDER BY DepDelay, ArrDel15 LIMIT 4
+SELECT DivWheelsOffs FROM mytable WHERE ArrDelayMinutes >= 240.0 AND DepTimeBlk BETWEEN '1200-1259' AND '1400-1459' AND Distance BETWEEN 543 AND 900 LIMIT 11
+SELECT DivWheelsOffs FROM mytable WHERE Carrier < 'MQ' LIMIT 4
+SELECT DivWheelsOffs FROM mytable WHERE DaysSinceEpoch <> 16253 AND Flights BETWEEN 1 AND 1 OR Quarter > 1 ORDER BY Origin, TaxiOut LIMIT 17
+SELECT DivWheelsOffs FROM mytable WHERE Flights > 1 OR CRSArrTime = 119 OR  REGEXP_LIKE(DestState, '.*S') LIMIT 10
+SELECT DivWheelsOffs FROM mytable WHERE NASDelay > 53 OR Year NOT IN (2014) OR TailNum BETWEEN 'N407WN' AND 'N576SW' ORDER BY DivReachedDest, DepDelayMinutes, OriginWac LIMIT 18
+SELECT DivWheelsOffs, DestCityMarketID FROM mytable WHERE DestStateName BETWEEN 'Virginia' AND 'Alabama' AND CRSArrTime >= 2204 AND DepartureDelayGroups BETWEEN 2 AND 11 LIMIT 6
+SELECT DivWheelsOffs, Origin FROM mytable WHERE DivTailNums IN ('N413SW', 'N248WN', 'N983DL') OR ArrDelay BETWEEN 28.0 AND 184.0 ORDER BY DestStateFips, ArrTime LIMIT 11
+SELECT DivWheelsOffs, OriginStateFips FROM mytable WHERE DivActualElapsedTime BETWEEN 1100 AND 472 ORDER BY ArrivalDelayGroups LIMIT 28
+SELECT DivWheelsOns FROM mytable WHERE ArrTimeBlk <> '1700-1759' OR OriginCityName IN ('Aspen, CO', 'Little Rock, AR', 'Charleston, SC', 'Saginaw/Bay City/Midland, MI') ORDER BY Quarter, DepDelayMinutes, OriginStateName LIMIT 6
+SELECT DivWheelsOns FROM mytable WHERE DivWheelsOns IN (1523, 932, 1706) OR DivAirportLandings BETWEEN 9 AND 1 OR UniqueCarrier > 'MQ' ORDER BY DivReachedDest LIMIT 21
+SELECT DivWheelsOns FROM mytable WHERE Quarter <= 3 AND DepDelay = 42.0 OR ArrTime = 2229 ORDER BY ActualElapsedTime, CarrierDelay, CancellationCode LIMIT 24
+SELECT DivWheelsOns, ArrTime, Origin FROM mytable WHERE ArrDel15 IN (1, 0, -9999) LIMIT 4
+SELECT DivWheelsOns, Carrier FROM mytable WHERE DepDel15 IN (0, -9999) OR WeatherDelay = 32 AND DivTotalGTimes BETWEEN 1 AND 14 ORDER BY FlightNum, UniqueCarrier
+SELECT DivWheelsOns, DestAirportSeqID FROM mytable WHERE OriginStateFips IN (1, 16, 28) OR DestCityMarketID IN (32467, 35249, 33830, 32320, 32891) OR OriginWac <> 61 ORDER BY DivActualElapsedTime, DestWac, TotalAddGTime LIMIT 11
+SELECT DivWheelsOns, DistanceGroup, WeatherDelay FROM mytable ORDER BY CarrierDelay, AirTime LIMIT 3
+SELECT DivWheelsOns, DivAirports, DestStateFips FROM mytable ORDER BY DepDel15, AirTime LIMIT 21
+SELECT DivWheelsOns, DivAirports, DivArrDelay FROM mytable ORDER BY DepDelayMinutes LIMIT 2
+SELECT DivWheelsOns, Flights, DivAirportLandings FROM mytable WHERE WheelsOn NOT IN (1140) AND Cancelled <= 0 LIMIT 13
+SELECT DivWheelsOns, LateAircraftDelay, DivAirportSeqIDs FROM mytable ORDER BY DestState, CarrierDelay, Origin LIMIT 7
+SELECT DivWheelsOns, OriginWac, Year FROM mytable WHERE DestWac NOT IN (81, 83, 62, 85, 53) AND ArrDelayMinutes >= 120.0 ORDER BY OriginStateFips, TaxiIn LIMIT 25
+SELECT DivWheelsOns, TaxiIn, Diverted FROM mytable WHERE  REGEXP_LIKE(OriginStateName, 'Conne.*ticut') OR ArrDelay >= 178.0 AND ArrDel15 = 1 LIMIT 5
+SELECT DivWheelsOns, Year FROM mytable WHERE Distance = 902 OR OriginAirportID = 12982 AND Diverted IN (1) ORDER BY DivArrDelay, CancellationCode LIMIT 3
+SELECT Diverted FROM mytable ORDER BY DepDelayMinutes LIMIT 10
+SELECT Diverted FROM mytable WHERE DayofMonth NOT IN (20, 4, 18, 15, 14) ORDER BY CancellationCode LIMIT 14
+SELECT Diverted FROM mytable WHERE Flights <= 1 OR Flights <> 1 ORDER BY TaxiOut
+SELECT Diverted, AirlineID FROM mytable WHERE DayofMonth NOT IN (31) AND SecurityDelay >= 10 OR DestWac IN (5, 41, 86, 87) ORDER BY WheelsOff LIMIT 27
+SELECT Diverted, DaysSinceEpoch FROM mytable WHERE OriginWac IN (44, 74) ORDER BY Diverted, DestStateName LIMIT 23
+SELECT Diverted, DepDel15 FROM mytable LIMIT 0
+SELECT Diverted, DestCityName FROM mytable LIMIT 16
+SELECT Diverted, FlightDate FROM mytable ORDER BY Diverted, AirTime LIMIT 12
+SELECT Diverted, OriginCityName, DepDel15 FROM mytable WHERE TaxiIn NOT IN (79, 75, 89) AND DestCityName > 'San Angelo, TX' ORDER BY Origin LIMIT 29
+SELECT Diverted, WeatherDelay FROM mytable WHERE OriginCityMarketID BETWEEN 32896 AND 33785 AND DepTimeBlk IN ('2200-2259', '2100-2159', '2300-2359', '1200-1259') LIMIT 20
+SELECT FirstDepTime FROM mytable LIMIT 6
+SELECT FirstDepTime FROM mytable WHERE DepTime <> 1602 AND ActualElapsedTime = 123 OR LateAircraftDelay = 21 LIMIT 21
+SELECT FirstDepTime FROM mytable WHERE WheelsOff BETWEEN 2205 AND 2230 ORDER BY Carrier, DivArrDelay LIMIT 10
+SELECT FirstDepTime FROM mytable WHERE Year NOT IN (2014) ORDER BY DistanceGroup, DepDelayMinutes LIMIT 23
+SELECT FirstDepTime, AirlineID, CRSElapsedTime FROM mytable ORDER BY ArrDel15, TailNum LIMIT 1
+SELECT FirstDepTime, ArrTimeBlk FROM mytable ORDER BY DivAirportLandings, CRSArrTime, DestAirportID LIMIT 18
+SELECT FirstDepTime, Carrier FROM mytable WHERE CRSDepTime <> 1826 OR FirstDepTime BETWEEN 2146 AND 1540 AND Year >= 2014 ORDER BY WeatherDelay, DivArrDelay LIMIT 9
+SELECT FirstDepTime, DaysSinceEpoch FROM mytable WHERE NASDelay = 150 LIMIT 29
+SELECT FirstDepTime, DestCityMarketID FROM mytable WHERE OriginStateName NOT IN ('Idaho', 'Massachusetts', 'Wisconsin') AND DestStateName BETWEEN 'Tennessee' AND 'Pennsylvania' OR AirTime >= 376 LIMIT 19
+SELECT FirstDepTime, DestCityMarketID, DaysSinceEpoch FROM mytable LIMIT 3
+SELECT FirstDepTime, DestStateFips FROM mytable WHERE NASDelay NOT IN (202, 305, 16, 60) AND DivTailNums IN ('N373SW') LIMIT 17
+SELECT FirstDepTime, DestStateName, Diverted FROM mytable LIMIT 13
+SELECT FirstDepTime, DestWac, ArrTimeBlk FROM mytable WHERE DivAirports IN ('ISN', 'AGS', 'DLH', 'ANC', 'ACV') OR FlightDate BETWEEN '2014-08-19' AND '2014-10-09' OR ArrTime NOT IN (1027, 130) ORDER BY WheelsOff LIMIT 7
+SELECT FirstDepTime, DistanceGroup FROM mytable ORDER BY Dest LIMIT 3
+SELECT FirstDepTime, DivAirportLandings, CRSElapsedTime FROM mytable WHERE OriginState BETWEEN 'VI' AND 'KS' OR DestStateFips BETWEEN 23 AND 42 ORDER BY DepDelay, ArrTime, DestCityName LIMIT 16
+SELECT FirstDepTime, DivAirportLandings, TaxiOut FROM mytable ORDER BY ArrTime, TotalAddGTime LIMIT 19
+SELECT FirstDepTime, DivReachedDest FROM mytable WHERE DestCityMarketID IN (34574) ORDER BY WheelsOff, WheelsOn, ArrTimeBlk LIMIT 20
+SELECT FirstDepTime, DivTailNums, ArrTime FROM mytable WHERE CarrierDelay = 375 ORDER BY DestCityName LIMIT 8
+SELECT FlightDate FROM mytable LIMIT 24
+SELECT FlightDate FROM mytable ORDER BY CRSDepTime, CarrierDelay, DivAirportLandings LIMIT 7
+SELECT FlightDate, ArrDelayMinutes, DaysSinceEpoch FROM mytable ORDER BY Quarter, OriginStateFips, Distance LIMIT 22
+SELECT FlightDate, ArrTimeBlk, ArrivalDelayGroups FROM mytable LIMIT 18
+SELECT FlightDate, DaysSinceEpoch FROM mytable WHERE CarrierDelay IN (70, 414) OR LateAircraftDelay NOT IN (63) OR Month <= 1 LIMIT 23
+SELECT FlightDate, DepDel15, CRSElapsedTime FROM mytable WHERE OriginCityMarketID >= 33244 AND OriginCityName IN ('Seattle, WA', 'Eagle, CO') AND DestCityName <= 'San Luis Obispo, CA' ORDER BY DivDistance, CRSArrTime LIMIT 20
+SELECT FlightDate, Dest, DivActualElapsedTime FROM mytable WHERE DivLongestGTimes < 135.0 ORDER BY WeatherDelay, DaysSinceEpoch LIMIT 22
+SELECT FlightDate, DivAirports, DestWac FROM mytable ORDER BY AirlineID, ArrTime LIMIT 11
+SELECT FlightDate, DivTotalGTimes, DestAirportSeqID FROM mytable ORDER BY SecurityDelay, DepTimeBlk, Distance LIMIT 12
+SELECT FlightDate, OriginCityName FROM mytable WHERE OriginCityName BETWEEN 'Crescent City, CA' AND 'Casper, WY' AND DayOfWeek IN (1, 2, 3, 7) OR Distance = 77 ORDER BY Origin, Year, TaxiOut LIMIT 18
+SELECT FlightDate, TotalAddGTime FROM mytable WHERE DivAirports < 'SIT' OR DepDelay NOT IN (329.0, 39.0) ORDER BY FlightNum LIMIT 0
+SELECT FlightDate, WheelsOn FROM mytable ORDER BY SecurityDelay, DepDel15, Flights LIMIT 20
+SELECT FlightNum FROM mytable ORDER BY NASDelay, Origin LIMIT 23
+SELECT FlightNum FROM mytable WHERE ArrDel15 NOT IN (0, 1, -9999) OR WheelsOn = 109 OR DayofMonth NOT IN (25, 14) ORDER BY DivActualElapsedTime, Diverted, ArrTimeBlk LIMIT 2
+SELECT FlightNum FROM mytable WHERE CarrierDelay BETWEEN 4 AND 78 ORDER BY ArrivalDelayGroups LIMIT 27
+SELECT FlightNum FROM mytable WHERE DayofMonth BETWEEN 18 AND 11 AND NASDelay BETWEEN 73 AND 39 OR Cancelled NOT IN (0) ORDER BY LateAircraftDelay, OriginState, Cancelled LIMIT 17
+SELECT FlightNum FROM mytable WHERE LateAircraftDelay > 132 LIMIT 25
+SELECT FlightNum, ActualElapsedTime FROM mytable WHERE ArrTime = 1004 OR ArrDelay >= 323.0 ORDER BY FlightNum, OriginCityMarketID, DestWac LIMIT 13
+SELECT FlightNum, ArrDelayMinutes FROM mytable ORDER BY DepDelay, DivAirportLandings, DivArrDelay LIMIT 13
+SELECT FlightNum, ArrDelayMinutes FROM mytable WHERE DivWheelsOffs = 1135 AND  REGEXP_LIKE(UniqueCarrier, '.*9') ORDER BY DayOfWeek, DestAirportID, DestCityName LIMIT 24
+SELECT FlightNum, ArrTime, OriginAirportID FROM mytable WHERE CRSElapsedTime <> 191 OR DepDelay = 33.0 AND OriginState BETWEEN 'WA' AND 'KY' ORDER BY DistanceGroup, DestStateFips, Origin LIMIT 1
+SELECT FlightNum, ArrTimeBlk FROM mytable WHERE Year NOT IN (2014) AND OriginAirportSeqID = 1307602 LIMIT 3
+SELECT FlightNum, DayofMonth FROM mytable WHERE DestAirportSeqID IN (1148102, 1532302, 1104103, 1383002) AND Dest NOT IN ('PAH') ORDER BY Month, DayOfWeek LIMIT 7
+SELECT FlightNum, Dest, TaxiIn FROM mytable WHERE DestCityMarketID IN (32896, 32556, 35841, 34057) AND DestWac = 81 LIMIT 21
+SELECT FlightNum, DestAirportID FROM mytable WHERE OriginStateFips <= 16 AND Carrier NOT IN ('F9', 'WN', 'FL') AND LateAircraftDelay BETWEEN 61 AND 98 ORDER BY DestState, Flights LIMIT 27
+SELECT FlightNum, DestAirportID, OriginAirportID FROM mytable ORDER BY Quarter, FirstDepTime, DivAirportLandings LIMIT 14
+SELECT FlightNum, DestState FROM mytable WHERE LateAircraftDelay = 108 LIMIT 18
+SELECT FlightNum, DestStateFips, TaxiOut FROM mytable LIMIT 21
+SELECT FlightNum, DivTailNums, DestCityMarketID FROM mytable WHERE DivTailNums = 'N8617E' OR OriginCityMarketID BETWEEN 32600 AND 31775 LIMIT 20
+SELECT FlightNum, DivWheelsOns, DestState FROM mytable WHERE DayOfWeek = 4 AND AirlineID BETWEEN 19393 AND 21171 OR OriginCityName NOT IN ('St. George, UT') LIMIT 22
+SELECT FlightNum, Diverted, DestWac FROM mytable WHERE DivTotalGTimes <= 85 OR Distance NOT IN (1204, 1192) ORDER BY DepDelayMinutes, ArrTime, DestWac LIMIT 25
+SELECT FlightNum, FlightDate, TotalAddGTime FROM mytable WHERE TotalAddGTime BETWEEN 34 AND 167 AND CRSElapsedTime = 556 ORDER BY TailNum LIMIT 11
+SELECT FlightNum, LateAircraftDelay FROM mytable LIMIT 1
+SELECT FlightNum, OriginStateName FROM mytable WHERE Distance BETWEEN 901 AND 1144 ORDER BY DestState, FlightDate LIMIT 10
+SELECT FlightNum, WeatherDelay, OriginAirportID FROM mytable WHERE DivAirportSeqIDs BETWEEN 1091802 AND 1029904 AND Origin > 'LGB' LIMIT 19
+SELECT Flights FROM mytable WHERE ArrTimeBlk BETWEEN '2200-2259' AND '2300-2359' ORDER BY DestCityMarketID LIMIT 8
+SELECT Flights FROM mytable WHERE DivTotalGTimes >= 36 OR CarrierDelay <= 32 ORDER BY DepTime, DestCityMarketID, DivArrDelay LIMIT 29
+SELECT Flights, CRSElapsedTime FROM mytable WHERE TaxiIn BETWEEN 75 AND 107 AND DestAirportID NOT IN (11624, 11049) AND DestState = 'AZ' ORDER BY DestStateFips LIMIT 14
+SELECT Flights, DaysSinceEpoch FROM mytable WHERE CRSArrTime BETWEEN 813 AND 1616 ORDER BY OriginStateName LIMIT 6
+SELECT Flights, DepDelayMinutes, WheelsOn FROM mytable WHERE Month NOT IN (1) OR CRSDepTime BETWEEN 1427 AND 1906 AND DestState IN ('MS', 'IN') ORDER BY OriginCityMarketID, SecurityDelay, DestStateName LIMIT 17
+SELECT Flights, DepTime FROM mytable WHERE WeatherDelay NOT IN (10, 100) AND FlightDate BETWEEN '2014-01-20' AND '2014-01-17' LIMIT 24
+SELECT Flights, DistanceGroup FROM mytable WHERE FlightNum <= 58 AND DestCityMarketID > 30141 ORDER BY DivAirportLandings, TailNum LIMIT 24
+SELECT Flights, Diverted FROM mytable WHERE SecurityDelay IN (0, 3, 41, 10) LIMIT 19
+SELECT Flights, FlightDate FROM mytable ORDER BY DepartureDelayGroups, SecurityDelay LIMIT 4
+SELECT Flights, OriginWac FROM mytable WHERE WeatherDelay IN (68, 37, 38) ORDER BY NASDelay LIMIT 15
+SELECT Flights, TaxiIn, DivAirportLandings FROM mytable WHERE DestCityMarketID = 31637 ORDER BY OriginCityName
+SELECT Flights, UniqueCarrier FROM mytable WHERE DivTotalGTimes BETWEEN 107 AND 105 ORDER BY DepartureDelayGroups, DepTimeBlk LIMIT 7
+SELECT Flights, WeatherDelay, SecurityDelay FROM mytable WHERE DestAirportID <> 11308 ORDER BY TaxiIn, DestCityName LIMIT 24
+SELECT LateAircraftDelay FROM mytable LIMIT 15
+SELECT LateAircraftDelay FROM mytable ORDER BY DivActualElapsedTime LIMIT 21
+SELECT LateAircraftDelay FROM mytable WHERE TailNum IN ('N684DA', 'N299WN', 'N765US', 'N5CCAA', 'N12924') ORDER BY LongestAddGTime, DepTime, DestStateName LIMIT 22
+SELECT LateAircraftDelay, ArrTime FROM mytable ORDER BY CarrierDelay, Year, DestCityMarketID LIMIT 20
+SELECT LateAircraftDelay, CarrierDelay FROM mytable WHERE TaxiOut BETWEEN 89 AND 126 AND OriginState IN ('SC', 'KS', 'RI', 'MO', 'DE') AND DestCityMarketID BETWEEN 32177 AND 31122 ORDER BY DivActualElapsedTime, DestStateFips, DepTime LIMIT 19
+SELECT LateAircraftDelay, DestAirportID, CRSDepTime FROM mytable WHERE DepDel15 <= 1 OR OriginStateFips IN (49, 47, 35, 13) ORDER BY LateAircraftDelay, Month, DaysSinceEpoch LIMIT 4
+SELECT LateAircraftDelay, Flights, OriginStateName FROM mytable WHERE ArrTime BETWEEN 1234 AND 1540 ORDER BY DivReachedDest, DestStateName, CRSDepTime LIMIT 22
+SELECT LateAircraftDelay, Origin FROM mytable WHERE Quarter NOT IN (1) LIMIT 11
+SELECT LateAircraftDelay, OriginCityName, AirTime FROM mytable ORDER BY TotalAddGTime, AirTime, WheelsOn
+SELECT LateAircraftDelay, OriginStateName, DivActualElapsedTime FROM mytable WHERE DivAirportLandings >= 0 OR DivWheelsOffs IN (1612, 2356, 1012, 326) LIMIT 3
+SELECT LateAircraftDelay, TotalAddGTime FROM mytable WHERE LateAircraftDelay <= 87 OR UniqueCarrier = 'AA' OR UniqueCarrier >= 'WN' ORDER BY DepDelayMinutes, Cancelled, DepDel15 LIMIT 14
+SELECT LateAircraftDelay, Year, DepTimeBlk FROM mytable WHERE ArrDel15 = 1 OR DivAirportSeqIDs BETWEEN 1495203 AND 1131502 OR DivAirportLandings NOT IN (0, 1, 2, 9) ORDER BY SecurityDelay, CancellationCode LIMIT 26
+SELECT LongestAddGTime FROM mytable ORDER BY AirlineID, CRSElapsedTime
+SELECT LongestAddGTime FROM mytable WHERE DistanceGroup BETWEEN 11 AND 5 AND Month BETWEEN 1 AND 7 OR LongestAddGTime BETWEEN 142 AND 13 ORDER BY LateAircraftDelay, FirstDepTime, ArrTime LIMIT 5
+SELECT LongestAddGTime FROM mytable WHERE OriginStateFips BETWEEN 31 AND 31 ORDER BY NASDelay, DestAirportSeqID, DestCityMarketID LIMIT 29
+SELECT LongestAddGTime, CRSElapsedTime, ArrDelay FROM mytable ORDER BY DivArrDelay, LongestAddGTime, OriginAirportID LIMIT 1
+SELECT LongestAddGTime, CancellationCode, OriginStateName FROM mytable WHERE CRSDepTime <= 1106 ORDER BY TaxiIn, DestAirportID, AirlineID LIMIT 20
+SELECT LongestAddGTime, Cancelled, DivTailNums FROM mytable ORDER BY DestWac, DivActualElapsedTime, DayOfWeek LIMIT 23
+SELECT LongestAddGTime, DivTailNums FROM mytable WHERE Flights <= 1 OR CRSDepTime BETWEEN 1911 AND 1129 LIMIT 15
+SELECT LongestAddGTime, OriginCityName, DayOfWeek FROM mytable WHERE ArrTime BETWEEN 1537 AND 2258 AND DivAirportLandings >= 0 AND DivTotalGTimes < 99 ORDER BY OriginState, Month LIMIT 24
+SELECT LongestAddGTime, OriginStateFips, DestStateFips FROM mytable WHERE DivActualElapsedTime = 141 ORDER BY Quarter, OriginStateName, Flights LIMIT 20
+SELECT LongestAddGTime, TotalAddGTime FROM mytable LIMIT 16
+SELECT LongestAddGTime, TotalAddGTime, DestCityMarketID FROM mytable WHERE DestStateName BETWEEN 'Puerto Rico' AND 'Connecticut' ORDER BY ArrDelay LIMIT 26
+SELECT LongestAddGTime, WeatherDelay FROM mytable ORDER BY CarrierDelay, UniqueCarrier, TailNum LIMIT 18
+SELECT LongestAddGTime, WeatherDelay FROM mytable WHERE TaxiIn IN (79, 109, 52, 38) OR SecurityDelay BETWEEN 0 AND -9999 AND FirstDepTime IN (2145, 1856, 1902) ORDER BY WheelsOn LIMIT 7
+SELECT MIN(div(DaysSinceEpoch,2)) FROM mytable
+SELECT Month FROM mytable LIMIT 27
+SELECT Month FROM mytable WHERE  REGEXP_LIKE(DestState, 'D.*') AND DivArrDelay BETWEEN 96 AND 935 LIMIT 14
+SELECT Month FROM mytable WHERE DivDistance NOT IN (114, 116, 229) AND TaxiIn = 63 ORDER BY CarrierDelay, DestStateName LIMIT 0
+SELECT Month FROM mytable WHERE DivReachedDest IN (1) AND CRSArrTime >= 843 ORDER BY OriginStateFips, TotalAddGTime LIMIT 14
+SELECT Month, CRSArrTime, DestCityName FROM mytable WHERE DestAirportSeqID BETWEEN 1452002 AND 1129202 AND OriginAirportSeqID > 1473003 AND DestCityName NOT IN ('St. Augustine, FL') ORDER BY ArrTimeBlk LIMIT 1
+SELECT Month, CancellationCode FROM mytable WHERE DepTime IN (2243, 615, 1957) ORDER BY DivAirportLandings, OriginStateFips LIMIT 7
+SELECT Month, DivTailNums, ArrivalDelayGroups FROM mytable WHERE DestStateName <> 'Hawaii' ORDER BY DayOfWeek, UniqueCarrier, DestStateName LIMIT 29
+SELECT Month, DivTailNums, DepDelay FROM mytable WHERE DestState <> 'MO' AND DivLongestGTimes >= 27.0 ORDER BY DepDelayMinutes LIMIT 11
+SELECT Month, OriginStateName, DestStateName FROM mytable ORDER BY Origin, DestCityMarketID LIMIT 16
+SELECT NASDelay FROM mytable WHERE ArrDelayMinutes = 188.0 LIMIT 12
+SELECT NASDelay FROM mytable WHERE ArrDelayMinutes BETWEEN 54.0 AND 208.0 AND CancellationCode BETWEEN 'B' AND 'noodles' OR OriginAirportID BETWEEN 11193 AND 10781 ORDER BY OriginState, CRSArrTime LIMIT 4
+SELECT NASDelay FROM mytable WHERE DepDelay IN (192.0, 23.0, 261.0, 178.0, 326.0) OR DayofMonth = 24 AND FirstDepTime BETWEEN 1440 AND 1733 ORDER BY WeatherDelay, ArrivalDelayGroups LIMIT 25
+SELECT NASDelay FROM mytable WHERE Dest BETWEEN 'SPI' AND 'SAV' OR DepDel15 BETWEEN 1 AND -9999 ORDER BY Origin LIMIT 9
+SELECT NASDelay, AirTime FROM mytable WHERE DivAirportIDs IN (14869, 11193, 13342, 11003, 10521) ORDER BY Origin LIMIT 15
+SELECT NASDelay, ArrDelay FROM mytable LIMIT 8
+SELECT NASDelay, ArrTimeBlk FROM mytable WHERE TaxiIn <> 10 OR ArrDelay NOT IN (96.0, 410.0, 231.0, 112.0) ORDER BY DestAirportID LIMIT 23
+SELECT NASDelay, DestCityMarketID FROM mytable ORDER BY DestAirportSeqID, Month LIMIT 21
+SELECT NASDelay, DestCityName, DestStateName FROM mytable WHERE DestWac NOT IN (5, 4, 52, 72, 74) ORDER BY Dest, Month LIMIT 4
+SELECT NASDelay, Distance FROM mytable WHERE ArrivalDelayGroups IN (3, 4, 5, 7) OR  REGEXP_LIKE(Origin, 'Y.*K') AND DayofMonth BETWEEN 10 AND 20 ORDER BY CarrierDelay LIMIT 27
+SELECT NASDelay, DivTotalGTimes, DayOfWeek FROM mytable WHERE DivAirportLandings NOT IN (2, 9) ORDER BY ArrDel15, AirlineID, DestAirportID LIMIT 2
+SELECT NASDelay, Diverted, DestWac FROM mytable WHERE ArrDelayMinutes = 180.0 ORDER BY WheelsOn, Distance LIMIT 8
+SELECT NASDelay, Origin FROM mytable WHERE DivWheelsOns BETWEEN 2237 AND 1408 LIMIT 20
+SELECT NASDelay, Origin, OriginAirportID FROM mytable WHERE DayOfWeek BETWEEN 5 AND 5 AND Dest BETWEEN 'WRG' AND 'GUC' AND DestCityName BETWEEN 'Topeka, KS' AND 'Pocatello, ID' ORDER BY ActualElapsedTime, DayofMonth, OriginStateName LIMIT 28
+SELECT Origin FROM mytable WHERE ArrTimeBlk BETWEEN '0600-0659' AND '2100-2159' OR DistanceGroup NOT IN (7, 11) ORDER BY FlightDate LIMIT 26
+SELECT Origin FROM mytable WHERE CarrierDelay IN (111, 141) LIMIT 29
+SELECT Origin FROM mytable WHERE DayOfWeek BETWEEN 1 AND 6 ORDER BY DivArrDelay, DivDistance, UniqueCarrier LIMIT 5
+SELECT Origin, ActualElapsedTime, DivTotalGTimes FROM mytable LIMIT 25
+SELECT Origin, DepDelay FROM mytable WHERE DestWac = 35 AND DivLongestGTimes IN (153.0, 19.0) ORDER BY ArrivalDelayGroups LIMIT 12
+SELECT Origin, DivTailNums FROM mytable WHERE DivDistance BETWEEN 128 AND 77 ORDER BY FirstDepTime, ArrDel15 LIMIT 2
+SELECT Origin, DivTotalGTimes, OriginStateName FROM mytable LIMIT 26
+SELECT Origin, LongestAddGTime, DivTailNums FROM mytable WHERE DestCityMarketID NOT IN (30918, 33792, 35165, 34109) OR CRSArrTime < 1202 AND Flights BETWEEN 1 AND 1 ORDER BY SecurityDelay, Month, Carrier LIMIT 26
+SELECT Origin, Month, OriginAirportSeqID FROM mytable WHERE DivTotalGTimes <= 182 OR DivAirportSeqIDs = 1228002 ORDER BY CarrierDelay, OriginCityName LIMIT 12
+SELECT Origin, OriginCityName, DestCityMarketID FROM mytable WHERE WheelsOff BETWEEN 1540 AND 2211 ORDER BY Origin, CancellationCode, DivDistance LIMIT 8
+SELECT Origin, OriginStateName, ArrDel15 FROM mytable WHERE DepDelayMinutes BETWEEN 110.0 AND 124.0 AND DepDelayMinutes NOT IN (151.0, 391.0, 51.0, 505.0, 187.0) AND CancellationCode IN ('C', 'A') ORDER BY ArrDelay LIMIT 24
+SELECT OriginAirportID FROM mytable WHERE CRSDepTime BETWEEN 959 AND 2056 AND  REGEXP_LIKE(ArrTimeBlk, '2000-.*059') ORDER BY DestStateFips LIMIT 9
+SELECT OriginAirportID FROM mytable WHERE Month BETWEEN 12 AND 7 OR TotalAddGTime = 12 OR Cancelled BETWEEN 1 AND 0 ORDER BY CRSElapsedTime LIMIT 12
+SELECT OriginAirportSeqID FROM mytable WHERE Origin = 'FCA' OR CRSArrTime BETWEEN 1521 AND 2305 ORDER BY DivDistance LIMIT 29
+SELECT OriginAirportSeqID, ArrDel15, UniqueCarrier FROM mytable WHERE DayOfWeek >= 3 OR DayofMonth <= 30 LIMIT 12
+SELECT OriginAirportSeqID, CRSArrTime FROM mytable WHERE FlightNum NOT IN (2438, 2642, 2012, 6051) OR DepDelayMinutes <> 973.0 OR WheelsOn BETWEEN 1544 AND 2344 ORDER BY DestStateName, AirlineID, CancellationCode LIMIT 12
+SELECT OriginAirportSeqID, DepDelay, OriginStateName FROM mytable WHERE Quarter BETWEEN 1 AND 1 LIMIT 29
+SELECT OriginAirportSeqID, DestAirportSeqID FROM mytable WHERE DestCityMarketID BETWEEN 35165 AND 35323 AND DestStateFips = 51 AND OriginCityName <= 'Manhattan/Ft. Riley, KS' ORDER BY Flights LIMIT 6
+SELECT OriginAirportSeqID, DestStateName, DayOfWeek FROM mytable ORDER BY DaysSinceEpoch, DayOfWeek LIMIT 11
+SELECT OriginAirportSeqID, DivLongestGTimes, ArrivalDelayGroups FROM mytable WHERE DepTime <> 922 ORDER BY Carrier, OriginStateName LIMIT 1
+SELECT OriginAirportSeqID, DivLongestGTimes, ArrivalDelayGroups FROM mytable WHERE TaxiOut BETWEEN 9 AND 37 OR DaysSinceEpoch BETWEEN 16090 AND 16080 ORDER BY TaxiOut LIMIT 0
+SELECT OriginAirportSeqID, DivReachedDest, LateAircraftDelay FROM mytable ORDER BY CarrierDelay, OriginWac LIMIT 0
+SELECT OriginAirportSeqID, OriginStateName FROM mytable WHERE ArrivalDelayGroups IN (-9999) AND Flights < 1 LIMIT 16
+SELECT OriginAirportSeqID, Quarter, DaysSinceEpoch FROM mytable WHERE OriginWac NOT IN (93, 39, 14) OR DepDel15 IN (1, 0, -9999) AND DaysSinceEpoch IN (16074, 16086) ORDER BY DayofMonth, OriginWac LIMIT 4
+SELECT OriginCityMarketID FROM mytable ORDER BY TaxiOut, OriginCityName LIMIT 26
+SELECT OriginCityMarketID FROM mytable WHERE OriginStateName <> 'Virginia' OR FlightNum IN (2943, 2359, 5054, 2909, 4865) OR ActualElapsedTime <> 232 LIMIT 1
+SELECT OriginCityMarketID, ArrTime FROM mytable WHERE Year < 2014 AND OriginState NOT IN ('PA', 'VI', 'IA', 'VA', 'RI') LIMIT 14
+SELECT OriginCityMarketID, CancellationCode, DivWheelsOffs FROM mytable WHERE WeatherDelay = 105 AND DivReachedDest = 0 OR DivAirports BETWEEN 'SMF' AND 'BOI' ORDER BY TaxiIn, DepTimeBlk
+SELECT OriginCityMarketID, Cancelled FROM mytable WHERE DepTime = 1220 AND ActualElapsedTime = 578 ORDER BY DivAirportLandings, DestStateFips LIMIT 0
+SELECT OriginCityMarketID, DayofMonth FROM mytable WHERE Dest BETWEEN 'MOD' AND 'RNO' AND DepartureDelayGroups BETWEEN 10 AND 12 LIMIT 14
+SELECT OriginCityMarketID, DayofMonth FROM mytable WHERE NASDelay = 168 AND TotalAddGTime = 106 OR WeatherDelay NOT IN (156, 218, 151, 41) ORDER BY ArrTimeBlk LIMIT 2
+SELECT OriginCityMarketID, DepDelay, CRSElapsedTime FROM mytable WHERE OriginAirportSeqID = 1133703 ORDER BY FlightNum, DestAirportSeqID LIMIT 27
+SELECT OriginCityMarketID, DepDelay, DayofMonth FROM mytable WHERE DayofMonth = 25 ORDER BY Year, DestStateFips LIMIT 12
+SELECT OriginCityMarketID, DepTimeBlk, CRSArrTime FROM mytable WHERE Distance >= 600 ORDER BY DestState, TailNum, DestAirportID LIMIT 23
+SELECT OriginCityMarketID, Distance, DestAirportID FROM mytable ORDER BY ArrTime, DepTimeBlk LIMIT 2
+SELECT OriginCityMarketID, DistanceGroup, DepTime FROM mytable WHERE Flights = 1 AND ArrDelayMinutes BETWEEN 246.0 AND 181.0 AND DivAirportSeqIDs BETWEEN 1160302 AND 1186703 ORDER BY DepartureDelayGroups LIMIT 20
+SELECT OriginCityMarketID, DivAirportLandings, DestStateName FROM mytable WHERE OriginState NOT IN ('WY') AND ArrDel15 BETWEEN 1 AND -9999 ORDER BY ArrDelay, DestAirportID LIMIT 5
+SELECT OriginCityMarketID, DivAirportSeqIDs FROM mytable WHERE DestState BETWEEN 'CO' AND 'OK' ORDER BY ArrDelayMinutes, ArrDelay LIMIT 27
+SELECT OriginCityMarketID, DivAirportSeqIDs FROM mytable WHERE Origin < 'BUR' LIMIT 24
+SELECT OriginCityMarketID, Origin, ArrivalDelayGroups FROM mytable LIMIT 3
+SELECT OriginCityName FROM mytable WHERE ArrDelayMinutes <= 148.0 OR TotalAddGTime BETWEEN 30 AND 21 ORDER BY DepDelay, Quarter, DestCityMarketID LIMIT 10
+SELECT OriginCityName FROM mytable WHERE DivLongestGTimes BETWEEN 85.0 AND 21.0 OR TailNum BETWEEN 'N28478' AND 'N26210' OR DistanceGroup IN (7, 8) ORDER BY DestWac, NASDelay LIMIT 12
+SELECT OriginCityName FROM mytable WHERE DivWheelsOffs IN (1832, 1350, 1810, 2205) OR ArrivalDelayGroups BETWEEN 1 AND 8 LIMIT 8
+SELECT OriginCityName, DepDel15, AirTime FROM mytable WHERE DivDistance IN (158) OR DestAirportSeqID < 1470903 ORDER BY DepTimeBlk LIMIT 9
+SELECT OriginCityName, DivActualElapsedTime FROM mytable WHERE ArrivalDelayGroups NOT IN (1, 0, -9999) OR DestStateFips BETWEEN 4 AND 49 ORDER BY DaysSinceEpoch LIMIT 1
+SELECT OriginCityName, OriginAirportSeqID, CRSArrTime FROM mytable WHERE DaysSinceEpoch = 16424 ORDER BY DepDel15, ArrivalDelayGroups LIMIT 27
+SELECT OriginState FROM mytable LIMIT 20
+SELECT OriginState FROM mytable WHERE Cancelled = 0 OR DivActualElapsedTime < 223 AND CarrierDelay = 2 ORDER BY SecurityDelay, OriginState, AirTime LIMIT 25
+SELECT OriginState FROM mytable WHERE DivTailNums BETWEEN 'N852AA' AND 'N832AS' AND  REGEXP_LIKE(CancellationCode, '.*') AND  REGEXP_LIKE(ArrTimeBlk, '2200-225.*') ORDER BY OriginAirportID LIMIT 21
+SELECT OriginState FROM mytable WHERE DivWheelsOns IN (1833, 1127, 8, 1759, 1208) OR Flights < 1 ORDER BY TailNum LIMIT 2
+SELECT OriginState, ArrTimeBlk FROM mytable WHERE CRSElapsedTime = 238 AND WheelsOn > 1317 LIMIT 10
+SELECT OriginState, CRSElapsedTime FROM mytable WHERE CRSElapsedTime IN (540, 89, 441, 643, 481) AND DestAirportSeqID BETWEEN 1074702 AND 1212903 ORDER BY LongestAddGTime LIMIT 10
+SELECT OriginState, DayofMonth, UniqueCarrier FROM mytable WHERE DivAirportLandings >= 9 OR OriginAirportID NOT IN (10980, 12888, 10685, 11111) ORDER BY DestStateFips LIMIT 3
+SELECT OriginState, DepDelay, OriginWac FROM mytable WHERE WheelsOff IN (1235, 2134) ORDER BY NASDelay, AirlineID, ArrDelay LIMIT 14
+SELECT OriginState, DepTime FROM mytable WHERE DepDelay IN (179.0, 320.0, -15.0, 94.0, 174.0) OR DepDelay BETWEEN 7.0 AND 139.0 ORDER BY OriginCityName, ArrDel15, Month LIMIT 8
+SELECT OriginState, Distance, DivActualElapsedTime FROM mytable WHERE DivTotalGTimes = 76 OR Cancelled = 1 OR DestAirportID <> 13851 ORDER BY TaxiOut, DivActualElapsedTime, DaysSinceEpoch LIMIT 5
+SELECT OriginState, DivReachedDest, DestAirportID FROM mytable WHERE DistanceGroup <> 6 AND DivAirportIDs IN (10918, 13476, 10245, 10599) OR WheelsOff <= 2039 LIMIT 9
+SELECT OriginState, DivTailNums, AirlineID FROM mytable ORDER BY Quarter LIMIT 8
+SELECT OriginState, FlightDate, CancellationCode FROM mytable WHERE DestCityName IN ('Durango, CO', 'Bellingham, WA', 'College Station/Bryan, TX') ORDER BY CRSArrTime LIMIT 21
+SELECT OriginState, FlightDate, DivArrDelay FROM mytable WHERE DestStateFips > 75 OR DivActualElapsedTime IN (389, 198, 307) AND Distance > 3801 ORDER BY DepDelayMinutes LIMIT 10
+SELECT OriginState, LongestAddGTime, DivArrDelay FROM mytable WHERE DepDelayMinutes >= 106.0 OR FirstDepTime IN (814, 1939) OR NASDelay NOT IN (211, 56, 16, 63) ORDER BY NASDelay, DestAirportID LIMIT 10
+SELECT OriginState, OriginStateFips, DestCityMarketID FROM mytable WHERE TailNum NOT IN ('N615MQ', 'N995DL', 'N537AA') ORDER BY DayOfWeek LIMIT 28
+SELECT OriginStateFips FROM mytable WHERE DestWac IN (43, 5, 35, 51, 85) OR Dest <= 'PIA' AND Diverted BETWEEN 0 AND 1 ORDER BY DestWac, DepDel15 LIMIT 22
+SELECT OriginStateFips FROM mytable WHERE OriginCityMarketID >= 30073 ORDER BY CRSElapsedTime LIMIT 9
+SELECT OriginStateFips, ActualElapsedTime, DivTotalGTimes FROM mytable WHERE OriginStateFips >= 2 LIMIT 16
+SELECT OriginStateFips, ArrTimeBlk, OriginAirportID FROM mytable WHERE DivArrDelay NOT IN (161, 864, 410, 9, 710) LIMIT 13
+SELECT OriginStateFips, DestAirportSeqID FROM mytable WHERE CRSArrTime IN (740, 1257, 712, 629) AND DivAirportIDs = 15370 ORDER BY OriginCityMarketID LIMIT 29
+SELECT OriginStateFips, Flights, ArrDel15 FROM mytable WHERE DivDistance NOT IN (306) AND DestCityName >= 'Harlingen/San Benito, TX' LIMIT 10
+SELECT OriginStateName FROM mytable ORDER BY DepDelayMinutes, CRSArrTime LIMIT 9
+SELECT OriginStateName FROM mytable WHERE  REGEXP_LIKE(UniqueCarrier, 'E.*') LIMIT 0
+SELECT OriginStateName FROM mytable WHERE DepDel15 <> 1 LIMIT 14
+SELECT OriginStateName, DivReachedDest, DestCityName FROM mytable ORDER BY TaxiIn, ArrTime, ArrTimeBlk LIMIT 19
+SELECT OriginWac FROM mytable ORDER BY DivAirportLandings, ArrDelay, TotalAddGTime LIMIT 20
+SELECT OriginWac FROM mytable WHERE DepDelayMinutes IN (212.0, 252.0, 69.0) OR DivLongestGTimes IN (24.0, 189.0, 43.0, 98.0, 152.0) AND  REGEXP_LIKE(Carrier, '.*O') LIMIT 3
+SELECT OriginWac FROM mytable WHERE DepTimeBlk IN ('2000-2059') OR OriginAirportSeqID >= 1084903 ORDER BY LongestAddGTime LIMIT 3
+SELECT OriginWac FROM mytable WHERE DestCityName NOT IN ('Gillette, WY', 'Watertown, NY') ORDER BY DivDistance, ArrDelay LIMIT 6
+SELECT OriginWac FROM mytable WHERE DivDistance > 181 LIMIT 19
+SELECT OriginWac FROM mytable WHERE FirstDepTime BETWEEN 1309 AND 1856 AND DestAirportID BETWEEN 12191 AND 10208 AND DivLongestGTimes BETWEEN 6.0 AND 64.0 LIMIT 29
+SELECT OriginWac FROM mytable WHERE Year = 2014 OR DayofMonth > 13 AND ArrTimeBlk BETWEEN '2200-2259' AND '1500-1559' LIMIT 1
+SELECT OriginWac, AirlineID, OriginStateName FROM mytable ORDER BY ArrDelayMinutes, DayofMonth LIMIT 7
+SELECT OriginWac, ArrDelay FROM mytable WHERE DivDistance NOT IN (2994, 546, 602, 729) AND ActualElapsedTime <= 370 ORDER BY ArrivalDelayGroups LIMIT 6
+SELECT OriginWac, ArrivalDelayGroups FROM mytable WHERE ArrTime BETWEEN 1540 AND 553 AND Diverted IN (1, 0) ORDER BY Month LIMIT 28
+SELECT OriginWac, CRSArrTime FROM mytable WHERE FlightNum BETWEEN 2987 AND 109 OR OriginAirportID = 14307 LIMIT 13
+SELECT OriginWac, CRSElapsedTime FROM mytable WHERE DestCityName < 'Idaho Falls, ID' OR DivAirportIDs IN (11823) OR Month NOT IN (3) ORDER BY Quarter, UniqueCarrier, DestStateFips LIMIT 12
+SELECT OriginWac, DayofMonth FROM mytable WHERE DayofMonth NOT IN (22, 28, 8, 10) AND NASDelay = 178 AND NASDelay = 155 ORDER BY OriginStateName, DepDelayMinutes, OriginState LIMIT 15
+SELECT OriginWac, Distance FROM mytable ORDER BY CRSElapsedTime LIMIT 27
+SELECT OriginWac, DistanceGroup FROM mytable WHERE TailNum NOT IN ('N748EV', 'N941MQ', 'N850UA', 'N623DL', 'N216WR') ORDER BY Month, DepDel15, OriginAirportID LIMIT 13
+SELECT OriginWac, Flights, DepDelay FROM mytable ORDER BY SecurityDelay, OriginCityMarketID, AirlineID LIMIT 21
+SELECT Quarter FROM mytable LIMIT 18
+SELECT Quarter FROM mytable WHERE Origin >= 'XNA' AND DivAirportSeqIDs IN (1019402, 1046902, 1584102) LIMIT 11
+SELECT Quarter, ActualElapsedTime, OriginAirportSeqID FROM mytable WHERE ArrDel15 BETWEEN 1 AND 1 AND DestAirportID IN (10268) OR AirlineID >= 19690 ORDER BY FlightNum, ArrDelayMinutes LIMIT 6
+SELECT Quarter, ArrTime, WeatherDelay FROM mytable WHERE DivWheelsOns > 233 ORDER BY Cancelled LIMIT 29
+SELECT Quarter, CancellationCode FROM mytable WHERE DivDistance > 448 AND DestStateName <= 'Mississippi' AND ArrTime <> 1804 ORDER BY Quarter, Distance, Month LIMIT 15
+SELECT Quarter, CarrierDelay, DivAirportSeqIDs FROM mytable WHERE FirstDepTime = 710 AND Cancelled BETWEEN 1 AND 0 ORDER BY DestState, DivArrDelay LIMIT 23
+SELECT Quarter, CarrierDelay, DivTotalGTimes FROM mytable WHERE Distance < 335 OR Dest BETWEEN 'JAX' AND 'DBQ' ORDER BY UniqueCarrier LIMIT 28
+SELECT Quarter, DestStateFips, DestWac FROM mytable WHERE DivWheelsOffs IN (2333, 337) ORDER BY LongestAddGTime, TaxiIn, DestAirportID LIMIT 24
+SELECT Quarter, Distance FROM mytable WHERE WheelsOn IN (2019, 1821, 2105) OR ArrDel15 NOT IN (1) LIMIT 17
+SELECT Quarter, Distance, OriginStateName FROM mytable WHERE DestAirportSeqID BETWEEN 1200702 AND 1562401 OR DivReachedDest >= -9999 ORDER BY DivActualElapsedTime, ArrivalDelayGroups, DaysSinceEpoch LIMIT 17
+SELECT Quarter, DivAirports FROM mytable ORDER BY FlightNum LIMIT 8
+SELECT Quarter, FlightDate, ArrivalDelayGroups FROM mytable WHERE DivArrDelay = 127 OR Flights < 1 AND FlightNum IN (2223, 1763, 2868, 2137) ORDER BY DepartureDelayGroups, DepDelay, OriginAirportID LIMIT 15
+SELECT Quarter, FlightDate, TailNum FROM mytable WHERE DivArrDelay <> 204 ORDER BY OriginAirportSeqID, OriginCityMarketID, ArrTime LIMIT 17
+SELECT Quarter, OriginCityName FROM mytable WHERE Carrier BETWEEN 'EV' AND 'OO' AND WheelsOff BETWEEN 1411 AND 354 ORDER BY Flights LIMIT 10
+SELECT Quarter, OriginStateFips FROM mytable ORDER BY DayofMonth LIMIT 25
+SELECT Quarter, OriginStateFips, DestWac FROM mytable LIMIT 19
+SELECT SecurityDelay FROM mytable ORDER BY Quarter, NASDelay LIMIT 17
+SELECT SecurityDelay FROM mytable WHERE DivWheelsOns <= 18 AND DivDistance BETWEEN 66 AND 160 ORDER BY CRSArrTime LIMIT 12
+SELECT SecurityDelay FROM mytable WHERE OriginCityMarketID BETWEEN 31638 AND 33486 LIMIT 13
+SELECT SecurityDelay, ArrDelay FROM mytable WHERE DistanceGroup BETWEEN 3 AND 8 AND Dest NOT IN ('HOU', 'GSP') ORDER BY ActualElapsedTime, ArrDelay LIMIT 7
+SELECT SecurityDelay, ArrTime, ArrDel15 FROM mytable WHERE DestStateName NOT IN ('New Hampshire') AND ArrTimeBlk > '1500-1559' OR DestCityName BETWEEN 'International Falls, MN' AND 'Ketchikan, AK' ORDER BY OriginStateName, Dest LIMIT 0
+SELECT SecurityDelay, ArrTime, DestStateFips FROM mytable WHERE Diverted NOT IN (0, 1) LIMIT 18
+SELECT SecurityDelay, DepTime, OriginWac FROM mytable ORDER BY OriginWac LIMIT 9
+SELECT SecurityDelay, DestStateFips, TaxiOut FROM mytable WHERE  REGEXP_LIKE(ArrTimeBlk, '18.*0-1859') AND WheelsOn < 2359 OR WheelsOff NOT IN (1305, 1029, 1324, 1300, 1052) ORDER BY TotalAddGTime LIMIT 8
+SELECT SecurityDelay, DestStateName FROM mytable LIMIT 8
+SELECT SecurityDelay, DestWac, DepTime FROM mytable WHERE DivArrDelay = 149 OR CarrierDelay = 239 AND AirlineID = 20366 ORDER BY DivAirportLandings, Year LIMIT 9
+SELECT SecurityDelay, DivAirportIDs, AirTime FROM mytable WHERE ArrDel15 NOT IN (1, 0, -9999) LIMIT 2
+SELECT SecurityDelay, DivAirports FROM mytable LIMIT 16
+SELECT SecurityDelay, DivDistance, DepDelay FROM mytable LIMIT 20
+SELECT SecurityDelay, OriginStateFips FROM mytable WHERE DivArrDelay BETWEEN 445 AND 343 OR OriginCityMarketID IN (32951, 33344, 30436) AND CRSArrTime = 1903 LIMIT 23
+SELECT SecurityDelay, OriginStateName, DaysSinceEpoch FROM mytable WHERE DayOfWeek = 4 ORDER BY CRSArrTime, TaxiOut, WheelsOn LIMIT 13
+SELECT SecurityDelay, Quarter, DivLongestGTimes FROM mytable WHERE Year >= 2014 ORDER BY UniqueCarrier, DestAirportID, Distance LIMIT 0
+SELECT SecurityDelay, TotalAddGTime FROM mytable WHERE WheelsOn BETWEEN 953 AND 819 OR FirstDepTime NOT IN (908, 1153, 710, 1018, 1449) LIMIT 18
+SELECT SecurityDelay, WeatherDelay FROM mytable WHERE DepTimeBlk >= '2000-2059' OR DayOfWeek BETWEEN 6 AND 5 OR FirstDepTime = 801 ORDER BY DestAirportSeqID
+SELECT TailNum FROM mytable WHERE DivTotalGTimes = 58 AND DepDelayMinutes BETWEEN 130.0 AND 253.0 ORDER BY OriginAirportID LIMIT 10
+SELECT TailNum FROM mytable WHERE Month <= 11 ORDER BY DivActualElapsedTime, ArrTime, DestAirportID LIMIT 2
+SELECT TailNum FROM mytable WHERE WheelsOn IN (404, -9999) OR FlightDate >= '2014-04-13' AND CancellationCode BETWEEN 'noodles' AND 'A' ORDER BY OriginWac, DestAirportID, WheelsOn LIMIT 22
+SELECT TailNum, DestCityName, Month FROM mytable ORDER BY DistanceGroup, DestWac LIMIT 6
+SELECT TailNum, DivAirportIDs FROM mytable WHERE OriginAirportSeqID BETWEEN 1288403 AND 1537602 AND OriginCityName BETWEEN 'Columbus, GA' AND 'San Antonio, TX' LIMIT 22
+SELECT TailNum, OriginWac FROM mytable WHERE OriginAirportSeqID BETWEEN 1393303 AND 1295402 LIMIT 2
+SELECT TaxiIn FROM mytable WHERE CRSElapsedTime NOT IN (186) AND OriginCityMarketID BETWEEN 30620 AND 32511 AND DayOfWeek BETWEEN 1 AND 4 ORDER BY DestWac, LateAircraftDelay LIMIT 26
+SELECT TaxiIn FROM mytable WHERE DestAirportSeqID BETWEEN 1468502 AND 1448702 OR DestState BETWEEN 'NC' AND 'PA' OR CarrierDelay IN (113, 64, 51, 290, 73) ORDER BY CarrierDelay, OriginAirportID LIMIT 7
+SELECT TaxiIn FROM mytable WHERE WheelsOn = 256 ORDER BY DivDistance, CRSElapsedTime, Cancelled LIMIT 23
+SELECT TaxiIn, AirTime FROM mytable WHERE ArrDelayMinutes IN (146.0, 109.0) ORDER BY DistanceGroup, SecurityDelay LIMIT 29
+SELECT TaxiIn, ArrDel15, AirTime FROM mytable WHERE DivAirportIDs BETWEEN 12992 AND 14107 AND CRSElapsedTime IN (224, 179, 208, 29) LIMIT 16
+SELECT TaxiIn, ArrTime, TotalAddGTime FROM mytable ORDER BY ArrTime LIMIT 13
+SELECT TaxiIn, Cancelled FROM mytable LIMIT 29
+SELECT TaxiIn, DivAirportIDs, Distance FROM mytable WHERE  REGEXP_LIKE(OriginCityName, 'College S.*ation/Bryan, TX') OR DivAirportLandings = 9 AND DivAirportIDs > 13303 ORDER BY DepTimeBlk LIMIT 19
+SELECT TaxiIn, DivAirportSeqIDs, DepTime FROM mytable WHERE DivAirportLandings = 9 AND ArrDelay >= 321.0 ORDER BY DayOfWeek, ArrDelayMinutes LIMIT 16
+SELECT TaxiIn, DivArrDelay FROM mytable WHERE DivArrDelay BETWEEN 640 AND 232 AND LateAircraftDelay <= 17 LIMIT 25
+SELECT TaxiIn, DivArrDelay, DaysSinceEpoch FROM mytable WHERE DivActualElapsedTime > 372 AND ArrDelayMinutes <> 60.0 OR TaxiIn BETWEEN 22 AND 84 ORDER BY Year, LongestAddGTime, ActualElapsedTime LIMIT 6
+SELECT TaxiIn, UniqueCarrier, OriginAirportID FROM mytable WHERE DestAirportID BETWEEN 11865 AND 14256 ORDER BY ArrTimeBlk, Month LIMIT 25
+SELECT TaxiOut FROM mytable ORDER BY ArrDelayMinutes, CRSElapsedTime LIMIT 5
+SELECT TaxiOut FROM mytable WHERE CRSDepTime NOT IN (2210, 716, 1510, 1153, 1517) AND ArrTimeBlk BETWEEN '1900-1959' AND '0700-0759' ORDER BY Flights, OriginCityMarketID LIMIT 25
+SELECT TaxiOut, Carrier, ArrivalDelayGroups FROM mytable WHERE Month IN (1) AND DivArrDelay BETWEEN 362 AND 399 OR TailNum NOT IN ('N266WN', 'N3GVAA', 'N593JB') LIMIT 20
+SELECT TaxiOut, DepDel15, DivWheelsOffs FROM mytable WHERE DivAirports < 'MCO' ORDER BY OriginState LIMIT 23
+SELECT TaxiOut, Dest FROM mytable WHERE ArrTime BETWEEN 807 AND 2154 AND ActualElapsedTime BETWEEN 172 AND 307 ORDER BY DestCityName LIMIT 5
+SELECT TaxiOut, DivArrDelay FROM mytable ORDER BY CarrierDelay, SecurityDelay, DepTime LIMIT 23
+SELECT TaxiOut, DivLongestGTimes FROM mytable ORDER BY DestState, Flights LIMIT 1
+SELECT TaxiOut, OriginState, OriginAirportID FROM mytable ORDER BY OriginCityMarketID, CRSArrTime, DestStateName LIMIT 7
+SELECT TaxiOut, TaxiIn, DayOfWeek FROM mytable WHERE TotalAddGTime NOT IN (8) AND CRSArrTime BETWEEN 923 AND 2150 ORDER BY Flights, WeatherDelay, DivActualElapsedTime LIMIT 15
+SELECT TaxiOut, TotalAddGTime FROM mytable WHERE DepartureDelayGroups IN (-1, 8) ORDER BY OriginStateFips, ArrivalDelayGroups LIMIT 2
+SELECT TotalAddGTime FROM mytable LIMIT 24
+SELECT TotalAddGTime FROM mytable WHERE DivAirports = 'ALO' OR WheelsOff IN (1655, 1225, 2314, 515) ORDER BY LateAircraftDelay, Flights, ArrTimeBlk LIMIT 24
+SELECT TotalAddGTime, AirlineID, DaysSinceEpoch FROM mytable WHERE DivWheelsOffs < 1231 OR ArrDelayMinutes BETWEEN 22.0 AND 164.0 AND DivAirportIDs IN (13476, 15376, 13029, 14831) ORDER BY TailNum LIMIT 13
+SELECT TotalAddGTime, ArrTime, Month FROM mytable LIMIT 28
+SELECT TotalAddGTime, DepDel15 FROM mytable WHERE CRSElapsedTime NOT IN (349, 183, 356, 41, 315) OR TaxiOut BETWEEN 78 AND 25 ORDER BY CancellationCode, DivArrDelay LIMIT 13
+SELECT TotalAddGTime, DivActualElapsedTime FROM mytable ORDER BY Carrier, CarrierDelay, DestCityName LIMIT 28
+SELECT TotalAddGTime, DivTotalGTimes FROM mytable WHERE CancellationCode IN ('A', 'B', 'C', 'noodles') ORDER BY DivReachedDest, CRSDepTime, DaysSinceEpoch LIMIT 13
+SELECT TotalAddGTime, NASDelay FROM mytable ORDER BY DepartureDelayGroups, TaxiIn, ArrTimeBlk LIMIT 18
+SELECT UniqueCarrier FROM mytable LIMIT 5
+SELECT UniqueCarrier FROM mytable ORDER BY DestState LIMIT 13
+SELECT UniqueCarrier FROM mytable WHERE DivArrDelay IN (68, 520) ORDER BY SecurityDelay, OriginWac LIMIT 21
+SELECT UniqueCarrier FROM mytable WHERE DivLongestGTimes IN (36.0, 118.0, 10.0) OR OriginAirportSeqID = 1127802 LIMIT 10
+SELECT UniqueCarrier FROM mytable WHERE FlightNum BETWEEN 26 AND 2973 AND CRSArrTime <= 639 OR NASDelay IN (6, 41) ORDER BY DistanceGroup, UniqueCarrier LIMIT 12
+SELECT UniqueCarrier FROM mytable WHERE Origin <> 'TOL' AND DepDelay = 256.0 AND NASDelay BETWEEN 368 AND 75 LIMIT 8
+SELECT UniqueCarrier, ArrDelay FROM mytable WHERE ActualElapsedTime NOT IN (203, 92, 97, 98) OR DestAirportID <> 11267 AND  REGEXP_LIKE(OriginStateName, '.*laska') ORDER BY DivArrDelay, Month LIMIT 21
+SELECT UniqueCarrier, DayofMonth, DestAirportID FROM mytable WHERE DestStateName IN ('Massachusetts', 'Virginia', 'Kentucky', 'Kansas', 'Washington') ORDER BY DestWac LIMIT 25
+SELECT UniqueCarrier, DaysSinceEpoch FROM mytable WHERE Carrier IN ('DL', 'B6', 'VX') OR Flights < 1 ORDER BY DivActualElapsedTime LIMIT 0
+SELECT UniqueCarrier, DepTime FROM mytable ORDER BY DestAirportSeqID, DestCityMarketID, WeatherDelay LIMIT 28
+SELECT UniqueCarrier, WeatherDelay, DivAirportIDs FROM mytable ORDER BY DivAirportLandings, ArrDelayMinutes LIMIT 1
+SELECT WeatherDelay FROM mytable ORDER BY TaxiIn LIMIT 2
+SELECT WeatherDelay FROM mytable WHERE ActualElapsedTime = 426 ORDER BY FlightDate, DivDistance, ArrivalDelayGroups
+SELECT WeatherDelay FROM mytable WHERE Carrier NOT IN ('EV', 'HA', 'MQ') OR DivWheelsOns IN (1144, 1259, 1558, 1303) AND DivAirportSeqIDs IN (1120302, 1160302, 1106603) ORDER BY TotalAddGTime, CancellationCode LIMIT 16
+SELECT WeatherDelay FROM mytable WHERE DivActualElapsedTime IN (652, 435, 920, 416) OR DestAirportSeqID IN (1239102, 1228002, 1177801) OR TailNum <> 'N797AS' ORDER BY OriginAirportID LIMIT 12
+SELECT WeatherDelay, AirlineID, DivTotalGTimes FROM mytable WHERE DivAirportLandings IN (2, 0, 9) OR SecurityDelay BETWEEN 4 AND 10 ORDER BY CRSDepTime, Month LIMIT 28
+SELECT WeatherDelay, CRSDepTime FROM mytable WHERE CRSDepTime BETWEEN 2127 AND 659 ORDER BY FlightNum LIMIT 5
+SELECT WeatherDelay, Cancelled, Dest FROM mytable WHERE AirTime <= 329 OR AirlineID < 20366 OR AirlineID BETWEEN 20304 AND 19805 ORDER BY OriginAirportID LIMIT 22
+SELECT WeatherDelay, DestCityName, DepTimeBlk FROM mytable WHERE ArrTimeBlk <= '1400-1459' AND DestAirportID = 10754 LIMIT 21
+SELECT WeatherDelay, Distance FROM mytable ORDER BY LateAircraftDelay, CancellationCode, DivAirportLandings LIMIT 11
+SELECT WheelsOff FROM mytable ORDER BY CancellationCode, DestWac, DepTime LIMIT 1
+SELECT WheelsOff FROM mytable WHERE ArrTime IN (154, 2214, 257, 702, 207) OR WheelsOff IN (1742, 2010) AND DepTime <= 2306 ORDER BY CRSDepTime, DayofMonth, TailNum LIMIT 16
+SELECT WheelsOff FROM mytable WHERE ArrivalDelayGroups NOT IN (10, 0, 7, -1) LIMIT 20
+SELECT WheelsOff FROM mytable WHERE DivTotalGTimes IN (98, 57, 9, 118) OR DepTime <> 1910 AND DayofMonth <> 25 LIMIT 29
+SELECT WheelsOff FROM mytable WHERE TaxiIn BETWEEN 36 AND 65 AND DestWac >= 88 LIMIT 27
+SELECT WheelsOff, ArrTimeBlk, OriginStateName FROM mytable WHERE DepDel15 NOT IN (0) AND DayofMonth BETWEEN 20 AND 14 ORDER BY Diverted, SecurityDelay, ArrDelayMinutes LIMIT 14
+SELECT WheelsOff, Carrier, DivArrDelay FROM mytable WHERE LateAircraftDelay IN (250, 24) ORDER BY DestWac, Distance, SecurityDelay LIMIT 14
+SELECT WheelsOff, Dest, OriginWac FROM mytable ORDER BY Diverted, TailNum, UniqueCarrier LIMIT 2
+SELECT WheelsOff, DestStateFips FROM mytable WHERE OriginWac >= 11 OR DepTimeBlk BETWEEN '1000-1059' AND '1600-1659' LIMIT 9
+SELECT WheelsOff, DivAirportSeqIDs, Month FROM mytable ORDER BY AirlineID, DestAirportID LIMIT 6
+SELECT WheelsOff, DivReachedDest FROM mytable ORDER BY TaxiOut, DepTime, Dest LIMIT 27
+SELECT WheelsOff, DivReachedDest, Cancelled FROM mytable ORDER BY DivReachedDest LIMIT 7
+SELECT WheelsOff, Diverted, OriginAirportID FROM mytable WHERE WheelsOn < 27 ORDER BY CRSElapsedTime LIMIT 13
+SELECT WheelsOff, LongestAddGTime FROM mytable WHERE DivTotalGTimes BETWEEN 92 AND 49 AND ActualElapsedTime <> 274 OR WheelsOff BETWEEN 1033 AND 1318 ORDER BY FlightNum, FlightDate, SecurityDelay LIMIT 21
+SELECT WheelsOff, Origin FROM mytable WHERE DayofMonth NOT IN (2, 6, 31, 22, 25) AND DepartureDelayGroups <> 2 ORDER BY OriginCityMarketID LIMIT 25
+SELECT WheelsOff, TaxiIn, Carrier FROM mytable WHERE OriginCityMarketID = 33933 ORDER BY ArrDelayMinutes LIMIT 29
+SELECT WheelsOff, TotalAddGTime, Month FROM mytable ORDER BY OriginState LIMIT 24
+SELECT WheelsOn FROM mytable ORDER BY AirlineID, TailNum LIMIT 12
+SELECT WheelsOn FROM mytable ORDER BY OriginAirportSeqID, WheelsOff, AirlineID LIMIT 29
+SELECT WheelsOn FROM mytable WHERE DivAirportIDs <= 12448 AND DepartureDelayGroups BETWEEN 1 AND 4 AND FlightDate > '2014-01-24' ORDER BY DayofMonth, DayOfWeek, OriginStateName LIMIT 29
+SELECT WheelsOn FROM mytable WHERE DivArrDelay > 284 OR Month = 6 AND WeatherDelay BETWEEN 59 AND 147 ORDER BY OriginWac, CRSArrTime LIMIT 8
+SELECT WheelsOn, ArrivalDelayGroups FROM mytable WHERE ArrDel15 NOT IN (0, -9999) AND ArrTimeBlk BETWEEN '0600-0659' AND '1700-1759' LIMIT 4
+SELECT WheelsOn, CRSDepTime, OriginAirportID FROM mytable WHERE Origin BETWEEN 'ATW' AND 'MYR' ORDER BY Diverted, DayOfWeek LIMIT 24
+SELECT WheelsOn, DaysSinceEpoch FROM mytable WHERE DestWac < 52 OR ArrDel15 > -9999 ORDER BY Carrier, Origin LIMIT 29
+SELECT WheelsOn, OriginAirportID FROM mytable WHERE DivReachedDest NOT IN (1) AND DivArrDelay BETWEEN 99 AND 870 LIMIT 3
+SELECT Year FROM mytable WHERE DestState BETWEEN 'HI' AND 'OK' LIMIT 0
+SELECT Year FROM mytable WHERE DestWac BETWEEN 54 AND 67 ORDER BY OriginAirportSeqID, OriginState LIMIT 15
+SELECT Year, AirTime, DestStateName FROM mytable ORDER BY LongestAddGTime LIMIT 3
+SELECT Year, ArrDel15 FROM mytable WHERE OriginState NOT IN ('LA') OR DepDelay IN (357.0, 41.0, 375.0, 126.0) AND DivAirportIDs BETWEEN 13487 AND 15027 ORDER BY DepDelay, ArrDelayMinutes LIMIT 3
+SELECT Year, ArrTimeBlk FROM mytable WHERE DestState IN ('PR', 'WY') AND OriginCityName IN ('Sacramento, CA', 'El Paso, TX', 'Butte, MT', 'Denver, CO', 'San Antonio, TX') ORDER BY Quarter, DestCityMarketID, ArrivalDelayGroups LIMIT 16
+SELECT Year, DestWac FROM mytable WHERE DepDelay IN (414.0, 174.0, 142.0, 38.0) AND Flights BETWEEN 1 AND 1 ORDER BY TailNum LIMIT 4
+SELECT Year, DivArrDelay, DivActualElapsedTime FROM mytable WHERE DivDistance IN (436, 814, 636, 88, 50) AND Flights NOT IN (1) LIMIT 15
+SELECT Year, DivTailNums, Dest FROM mytable WHERE DaysSinceEpoch BETWEEN 16074 AND 16094 OR DivReachedDest NOT IN (0, -9999) OR DivWheelsOns IN (1810, 928, 1646, 1312) ORDER BY FlightDate, DestAirportSeqID, DepTimeBlk LIMIT 16
+SELECT Year, FlightNum, LongestAddGTime FROM mytable WHERE DivAirportIDs IN (14307, 14689, 10397) OR CarrierDelay >= 21 OR OriginCityMarketID BETWEEN 32467 AND 30631 ORDER BY WheelsOff, Quarter, DepTime LIMIT 29
+SELECT Year, LongestAddGTime, CRSDepTime FROM mytable WHERE CancellationCode > 'A' OR LateAircraftDelay NOT IN (122, 176, 246) ORDER BY OriginCityMarketID, ArrDelayMinutes, CancellationCode LIMIT 20
+SELECT Year, OriginAirportID FROM mytable WHERE DivLongestGTimes BETWEEN 144.0 AND 107.0 AND DivWheelsOns BETWEEN 1202 AND 1752 ORDER BY CRSDepTime, Origin, DivAirportLandings LIMIT 24
+SELECT Year, OriginState, ArrDel15 FROM mytable WHERE OriginAirportID IN (12343, 10980, 11695, 10423) OR  REGEXP_LIKE(DestState, 'I.*') OR FirstDepTime = 534 ORDER BY DivReachedDest, ArrDelayMinutes, Distance LIMIT 24
+SELECT Year, OriginWac, CRSDepTime FROM mytable WHERE DivDistance BETWEEN 1011 AND 68 OR UniqueCarrier < 'VX' LIMIT 4
+SELECT Year, Quarter FROM mytable WHERE DestCityMarketID NOT IN (34960, 33316, 33127, 31973, 32982) LIMIT 19
+SELECT Year, TaxiOut FROM mytable ORDER BY CarrierDelay LIMIT 9
+SELECT column1, column5, column11 FROM testTable ORDER BY column6, column1
+SELECT column1, column5, column11 FROM testTable ORDER BY column6, column1 WHERE column1 > 100000000 AND column3 BETWEEN 20000000 AND 1000000000 AND column5 = 'gFuH' AND (column6 < 500000000 OR column11 NOT IN ('t', 'P')) AND daysSinceEpoch = 126164076
+SELECT column1, column5, column6 FROM testTable ORDER BY column5, column9
+SELECT column1, column5, column6 FROM testTable ORDER BY column5, column9 WHERE column1 > 100000000 AND column2 BETWEEN 20000000 AND 1000000000 AND column3 <> 'w' AND (column6 < 500000 OR column7 NOT IN (225, 407)) AND daysSinceEpoch = 1756015683
+select $docId, $segmentName, $hostName from mytable where $docId < 5 limit 50
+select $docId, $segmentName, $hostName from mytable where $docId = 5 limit 50
+select $docId, $segmentName, $hostName from mytable where $docId > 19998 limit 50
diff --git a/pinot-common/src/thrift/query.thrift b/pinot-common/src/thrift/query.thrift
new file mode 100644
index 0000000..98329f5
--- /dev/null
+++ b/pinot-common/src/thrift/query.thrift
@@ -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.
+ */
+namespace java org.apache.pinot.common.request
+
+struct DataSource {
+  1: optional string tableName;
+}
+
+struct PinotQuery {
+  1: optional i32 version;
+  2: optional DataSource dataSource;
+  3: optional list<Expression> selectList;
+  4: optional Expression filterExpression;
+  5: optional list<Expression> groupByList;
+  6: optional list<Expression> orderByList;
+  7: optional Expression havingExpression;
+  8: optional i32 limit = 10;
+  9: optional i32 offset = 0;
+  10: optional map<string, string> debugOptions;
+  11: optional map<string, string> queryOptions;
+}
+
+enum ExpressionType {
+  LITERAL,
+  IDENTIFIER,
+  FUNCTION
+}
+
+struct Expression {
+  1: required ExpressionType type;
+  2: optional Function functionCall;
+  3: optional Literal literal;
+  4: optional Identifier identifier;
+}
+
+struct Identifier {
+  1: required string name;
+}
+
+union Literal {
+  1: optional bool boolValue;
+  2: optional byte byteValue;
+  3: optional i16 shortValue;
+  4: optional i32 intValue;
+  5: optional i64 longValue;
+  6: optional double doubleValue;
+  7: optional string stringValue;
+  8: optional binary binaryValue;
+}
+
+struct Function {
+  1: required string operator;
+  2: optional list<Expression> operands;
+}
diff --git a/pinot-common/src/thrift/request.thrift b/pinot-common/src/thrift/request.thrift
index 8108991..0072704 100644
--- a/pinot-common/src/thrift/request.thrift
+++ b/pinot-common/src/thrift/request.thrift
@@ -17,6 +17,7 @@
  * under the License.
  */
 namespace java org.apache.pinot.common.request
+include "query.thrift"
 
 /**
  * AUTO GENERATED: DO NOT EDIT
@@ -152,6 +153,7 @@ struct BrokerRequest {
  14: optional map<string, string> queryOptions;
  15: optional HavingFilterQuery havingFilterQuery;
  16: optional HavingFilterQueryMap havingFilterSubQueryMap;
+ 17: optional query.PinotQuery pinotQuery;
 }
 
 /**
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/reduce/InAndNotInComparison.java b/pinot-core/src/main/java/org/apache/pinot/core/query/reduce/InAndNotInComparison.java
index e7106f9..15ab332 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/query/reduce/InAndNotInComparison.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/query/reduce/InAndNotInComparison.java
@@ -29,6 +29,7 @@ public class InAndNotInComparison extends ComparisonFunction {
 
   public InAndNotInComparison(String values, boolean isItNotIn, AggregationInfo aggregationInfo) {
     super(aggregationInfo);
+    this._isItNotIn = isItNotIn;
     String[] splitedValues = values.split("\\t\\t");
     int size = splitedValues.length;
     this._values = new double[size];
diff --git a/pinot-core/src/test/java/org/apache/pinot/reduce/HavingClauseComparisonTests.java b/pinot-core/src/test/java/org/apache/pinot/reduce/HavingClauseComparisonTests.java
index 1961e6f..8a438ae 100644
--- a/pinot-core/src/test/java/org/apache/pinot/reduce/HavingClauseComparisonTests.java
+++ b/pinot-core/src/test/java/org/apache/pinot/reduce/HavingClauseComparisonTests.java
@@ -36,7 +36,6 @@ import org.apache.pinot.pql.parsers.Pql2Compiler;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-
 public class HavingClauseComparisonTests {
   @Test
   public void testBetweenComparison() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org