drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [16/38] git commit: DRILL-257: Move SQL parsing to server side. Switch to Avatica based JDBC driver. Update QuerySubmitter to support SQL queries. Update SqlAccesors to support getObject() Remove ref, clean up SQL packages some. Various performance fixes
Date Tue, 04 Mar 2014 08:07:43 GMT
DRILL-257: Move SQL parsing to server side.
Switch to Avatica based JDBC driver.
Update QuerySubmitter to support SQL queries.
Update SqlAccesors to support getObject()
Remove ref, clean up SQL packages some.
Various performance fixes.  Updating result set so first set of results must be returned before control is return to client to allow metadata to populate for aggressive tools like sqlline
Move timeout functionality to TestTools.
Update Expression materializer so that it will return a nullable int if a field is not found.
Update Project record batch to support simple wildcard queries.
Updates to move JSON record reader test to expecting VarCharVector.getObject to return a String rather than a byte[].


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/b3460af8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/b3460af8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/b3460af8

Branch: refs/heads/master
Commit: b3460af8f3d47ce3a1ac4289998d255a9307b1ea
Parents: cdf46fd
Author: Jacques Nadeau <jacques@apache.org>
Authored: Thu Jan 30 10:56:27 2014 -0800
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Mon Mar 3 23:22:16 2014 -0800

----------------------------------------------------------------------
 common/pom.xml                                  |  39 +-
 .../org/apache/drill/common/JSONOptions.java    |  48 +-
 .../org/apache/drill/common/defs/OrderDef.java  |  57 --
 .../apache/drill/common/defs/PartitionDef.java  |  58 --
 .../drill/common/expression/FieldReference.java |   3 +
 .../common/expression/FunctionRegistry.java     |   3 +
 .../drill/common/expression/SchemaPath.java     |   2 +-
 .../common/expression/ValueExpressions.java     |  31 +-
 .../drill/common/logical/LogicalPlan.java       |  12 +-
 .../common/logical/LogicalPlanBuilder.java      |  11 +-
 .../drill/common/logical/PlanProperties.java    |  22 +-
 .../common/logical/data/AbstractBuilder.java    |  37 ++
 .../logical/data/AbstractSingleBuilder.java     |  41 ++
 .../common/logical/data/GroupingAggregate.java  | 100 ++++
 .../apache/drill/common/logical/data/Join.java  |  98 +++-
 .../apache/drill/common/logical/data/Order.java |  82 ++-
 .../drill/common/logical/data/Project.java      |  53 +-
 .../apache/drill/common/logical/data/Scan.java  |  32 +-
 .../drill/common/logical/data/ScanBuilder.java  |  49 --
 .../logical/data/SingleInputOperator.java       |   8 +-
 .../apache/drill/common/logical/data/Store.java |  39 +-
 .../drill/common/logical/data/StoreBuilder.java |  49 --
 .../apache/drill/common/logical/data/Union.java |  34 +-
 .../data/visitors/AbstractLogicalVisitor.java   |   5 +
 .../logical/data/visitors/LogicalVisitor.java   |  22 +-
 .../org/apache/drill/common/types/Types.java    |  79 +++
 .../org/apache/drill/common/util/TestTools.java |  34 ++
 contrib/sqlline/pom.xml                         |   1 -
 distribution/pom.xml                            |  54 +-
 distribution/src/assemble/bin.xml               |  47 +-
 distribution/src/resources/sqlline              |   2 +-
 exec/bufferl/pom.xml                            |   4 +-
 exec/java-exec/pom.xml                          |  14 +-
 .../src/main/codegen/includes/vv_imports.ftl    |   3 +
 .../codegen/templates/FixedValueVectors.java    |   4 +
 .../codegen/templates/RepeatedValueVectors.java |   5 +
 .../main/codegen/templates/SqlAccessors.java    | 117 ++++
 .../src/main/codegen/templates/TypeHelper.java  |  21 +-
 .../templates/VariableLengthVectors.java        |  21 +
 .../org/apache/drill/exec/cache/HazelCache.java |   5 +
 .../apache/drill/exec/client/DrillClient.java   |  35 +-
 .../drill/exec/client/QuerySubmitter.java       | 112 ++--
 .../apache/drill/exec/compile/MergeAdapter.java |   3 -
 .../exec/expr/ExpressionTreeMaterializer.java   |  13 +-
 .../apache/drill/exec/ops/FragmentContext.java  |   7 +
 .../org/apache/drill/exec/ops/QueryContext.java |  11 +
 .../apache/drill/exec/opt/BasicOptimizer.java   |  22 +-
 .../exec/physical/config/MergeJoinPOP.java      |  13 +-
 .../physical/config/MergingReceiverPOP.java     |  18 +-
 .../config/OrderedPartitionExchange.java        |  18 +-
 .../physical/config/OrderedPartitionSender.java |  25 +-
 .../physical/config/SingleMergeExchange.java    |  16 +-
 .../apache/drill/exec/physical/config/Sort.java |   9 +-
 .../exec/physical/impl/join/JoinTemplate.java   |   5 +-
 .../exec/physical/impl/join/MergeJoinBatch.java |   3 +-
 .../physical/impl/join/MergeJoinCreator.java    |   8 +-
 .../impl/mergereceiver/MergingRecordBatch.java  |  10 +-
 .../OrderedPartitionRecordBatch.java            |  23 +-
 .../impl/project/ProjectRecordBatch.java        |  70 ++-
 .../exec/physical/impl/sort/SortBatch.java      |  11 +-
 .../exec/planner/logical/DrillAggregateRel.java | 108 ++++
 .../planner/logical/DrillAggregateRule.java     |  53 ++
 .../exec/planner/logical/DrillFilterRel.java    |  66 +++
 .../exec/planner/logical/DrillFilterRule.java   |  42 ++
 .../exec/planner/logical/DrillImplementor.java  |  88 +++
 .../exec/planner/logical/DrillJoinRel.java      | 165 ++++++
 .../exec/planner/logical/DrillJoinRule.java     |  57 ++
 .../exec/planner/logical/DrillLimitRel.java     |  73 +++
 .../exec/planner/logical/DrillLimitRule.java    |  59 ++
 .../drill/exec/planner/logical/DrillOptiq.java  | 200 +++++++
 .../exec/planner/logical/DrillParseContext.java |  36 ++
 .../exec/planner/logical/DrillProjectRel.java   |  98 ++++
 .../exec/planner/logical/DrillProjectRule.java  |  46 ++
 .../drill/exec/planner/logical/DrillRel.java    |  33 ++
 .../exec/planner/logical/DrillRuleSets.java     |  92 +++
 .../exec/planner/logical/DrillScanRel.java      |  62 ++
 .../exec/planner/logical/DrillScanRule.java     |  43 ++
 .../exec/planner/logical/DrillScreenRel.java    |  76 +++
 .../exec/planner/logical/DrillSortRel.java      | 100 ++++
 .../exec/planner/logical/DrillSortRule.java     |  51 ++
 .../exec/planner/logical/DrillStoreRel.java     |  45 ++
 .../drill/exec/planner/logical/DrillTable.java  | 107 ++++
 .../exec/planner/logical/DrillUnionRel.java     |  71 +++
 .../exec/planner/logical/DrillUnionRule.java    |  48 ++
 .../exec/planner/logical/DrillValuesRel.java    |  57 ++
 .../exec/planner/logical/DrillValuesRule.java   |  39 ++
 .../planner/logical/EnumerableDrillRule.java    |  47 ++
 .../drill/exec/planner/logical/ExprHelper.java  |  41 ++
 .../planner/logical/RelDataTypeDrillImpl.java   | 142 +++++
 .../exec/planner/logical/RelOptHelper.java      |  44 ++
 .../planner/logical/ScanFieldDeterminer.java    | 217 +++++++
 .../exec/planner/logical/StorageEngines.java    |  74 +++
 .../exec/planner/sql/DrillSchemaFactory.java    |  96 ++++
 .../drill/exec/planner/sql/DrillSqlWorker.java  | 123 ++++
 .../planner/sql/ExpandingConcurrentMap.java     | 223 ++++++++
 .../exec/planner/sql/FileSystemSchema.java      | 117 ++++
 .../exec/planner/torel/ConversionContext.java   | 167 ++++++
 .../apache/drill/exec/record/BatchSchema.java   |   9 +
 .../drill/exec/record/VectorContainer.java      |   9 +-
 .../org/apache/drill/exec/rpc/BasicClient.java  |   6 +-
 .../exec/rpc/BasicClientWithConnection.java     |   5 +-
 .../apache/drill/exec/rpc/RemoteConnection.java |   3 +-
 .../drill/exec/rpc/user/ConnectionThrottle.java |  22 +
 .../drill/exec/rpc/user/QueryResultHandler.java |  13 +-
 .../apache/drill/exec/rpc/user/UserClient.java  |   4 +-
 .../exec/rpc/user/UserResultsListener.java      |   2 +-
 .../apache/drill/exec/rpc/user/UserServer.java  |   2 +-
 .../drill/exec/server/DrillbitContext.java      |  35 ++
 .../exec/store/parquet/ParquetGroupScan.java    |   2 +-
 .../store/parquet/ParquetSchemaProvider.java    |   2 +-
 .../store/parquet/ParquetStorageEngine.java     |   2 +-
 .../org/apache/drill/exec/vector/BitVector.java |   4 +
 .../apache/drill/exec/vector/ValueVector.java   |   2 +
 .../vector/accessor/AbstractSqlAccessor.java    | 123 ++++
 .../drill/exec/vector/accessor/SqlAccessor.java |  67 +++
 .../org/apache/drill/exec/work/WorkManager.java |   3 +-
 .../apache/drill/exec/work/foreman/Foreman.java | 131 ++++-
 .../drill/exec/work/foreman/QueryManager.java   |  11 +-
 .../src/main/resources/storage-engines.json     |  29 +
 .../physical/impl/TestSimpleFragmentRun.java    |   7 +-
 .../drill/exec/store/JSONRecordReaderTest.java  |  22 +-
 .../exec/store/ParquetRecordReaderTest.java     |  22 +-
 .../exec/store/TestParquetPhysicalPlan.java     |  17 +-
 .../store/parquet/ParquetRecordReaderTest.java  |   3 +-
 exec/pom.xml                                    |   1 -
 exec/ref/pom.xml                                | 107 ----
 .../drill/exec/ref/BasicStatusHandle.java       |  44 --
 .../apache/drill/exec/ref/ExecRefConstants.java |  27 -
 .../apache/drill/exec/ref/IteratorRegistry.java |  70 ---
 .../org/apache/drill/exec/ref/ROPConverter.java | 154 -----
 .../apache/drill/exec/ref/RecordIterator.java   |  67 ---
 .../apache/drill/exec/ref/RecordPointer.java    |  37 --
 .../drill/exec/ref/ReferenceInterpreter.java    | 155 -----
 .../drill/exec/ref/ReferenceTransform.java      |  34 --
 .../org/apache/drill/exec/ref/RunOutcome.java   |  53 --
 .../apache/drill/exec/ref/UnbackedRecord.java   | 131 -----
 .../drill/exec/ref/eval/BaseBasicEvaluator.java |  42 --
 .../exec/ref/eval/BasicEvaluatorFactory.java    | 106 ----
 .../drill/exec/ref/eval/BoundarySubscriber.java |  22 -
 .../drill/exec/ref/eval/EvaluatorFactory.java   |  59 --
 .../drill/exec/ref/eval/EvaluatorTypes.java     |  58 --
 .../drill/exec/ref/eval/FieldEvaluator.java     |  46 --
 .../apache/drill/exec/ref/eval/IfEvaluator.java |  81 ---
 .../exec/ref/eval/SimpleEvaluationVisitor.java  | 145 -----
 .../exec/ref/eval/fn/ComparisonEvaluators.java  | 137 -----
 .../exec/ref/eval/fn/FunctionArguments.java     |  87 ---
 .../exec/ref/eval/fn/FunctionEvaluator.java     |  26 -
 .../ref/eval/fn/FunctionEvaluatorRegistry.java  | 110 ----
 .../drill/exec/ref/eval/fn/MathEvaluators.java  | 106 ----
 .../exec/ref/eval/fn/StringEvaluators.java      |  52 --
 .../fn/agg/AggregatingWrapperEvaluator.java     |  54 --
 .../exec/ref/eval/fn/agg/CountAggregator.java   |  75 ---
 .../exec/ref/eval/fn/agg/SumAggregator.java     | 103 ----
 .../exec/ref/exceptions/MajorException.java     |  46 --
 .../exec/ref/exceptions/RecordException.java    |  48 --
 .../exec/ref/exceptions/SetupException.java     |  46 --
 .../exec/ref/rops/AbstractBlockingOperator.java |  83 ---
 .../apache/drill/exec/ref/rops/BaseSinkROP.java | 113 ----
 .../drill/exec/ref/rops/BoundaryListener.java   |  25 -
 .../exec/ref/rops/CollapsingAggregateROP.java   | 269 ---------
 .../apache/drill/exec/ref/rops/ConstantROP.java | 109 ----
 .../apache/drill/exec/ref/rops/DataWriter.java  |  49 --
 .../apache/drill/exec/ref/rops/FilterROP.java   |  81 ---
 .../apache/drill/exec/ref/rops/FlattenROP.java  | 140 -----
 .../org/apache/drill/exec/ref/rops/JoinROP.java | 315 -----------
 .../apache/drill/exec/ref/rops/LimitROP.java    |  87 ---
 .../apache/drill/exec/ref/rops/OrderROP.java    | 201 -------
 .../apache/drill/exec/ref/rops/ProjectROP.java  |  95 ----
 .../drill/exec/ref/rops/ProxySimpleRecord.java  |  79 ---
 .../org/apache/drill/exec/ref/rops/ROP.java     |  28 -
 .../org/apache/drill/exec/ref/rops/ROPBase.java |  61 --
 .../drill/exec/ref/rops/ReferenceOperator.java  |  26 -
 .../exec/ref/rops/ReferenceOperatorBase.java    |  39 --
 .../org/apache/drill/exec/ref/rops/ScanROP.java |  70 ---
 .../apache/drill/exec/ref/rops/SegmentROP.java  | 118 ----
 .../drill/exec/ref/rops/SingleInputROPBase.java |  49 --
 .../org/apache/drill/exec/ref/rops/SinkROP.java |  30 -
 .../apache/drill/exec/ref/rops/StoreROP.java    |  63 ---
 .../drill/exec/ref/rops/TransformROP.java       |  89 ---
 .../apache/drill/exec/ref/rops/UnionROP.java    | 107 ----
 .../drill/exec/ref/rops/WindowFrameROP.java     | 321 -----------
 .../apache/drill/exec/ref/rse/ClasspathRSE.java |  93 ---
 .../apache/drill/exec/ref/rse/ConsoleRSE.java   |  66 ---
 .../drill/exec/ref/rse/FileSystemRSE.java       | 161 ------
 .../drill/exec/ref/rse/JSONDataWriter.java      | 142 -----
 .../drill/exec/ref/rse/JSONRecordReader.java    | 183 ------
 .../drill/exec/ref/rse/OutputStreamWriter.java  |  78 ---
 .../org/apache/drill/exec/ref/rse/QueueRSE.java | 146 -----
 .../org/apache/drill/exec/ref/rse/RSEBase.java  |  71 ---
 .../apache/drill/exec/ref/rse/RSERegistry.java  |  87 ---
 .../apache/drill/exec/ref/rse/RecordReader.java |  28 -
 .../drill/exec/ref/rse/RecordRecorder.java      |  32 --
 .../exec/ref/rse/ReferenceStorageEngine.java    |  45 --
 .../drill/exec/ref/util/BatchBreaker.java       |  46 --
 .../apache/drill/exec/ref/util/ByteRange.java   |  34 --
 .../drill/exec/ref/values/BaseArrayValue.java   |  86 ---
 .../drill/exec/ref/values/BaseDataValue.java    |  82 ---
 .../drill/exec/ref/values/BaseMapValue.java     | 111 ----
 .../drill/exec/ref/values/BooleanValue.java     |  22 -
 .../drill/exec/ref/values/BytesValue.java       |  28 -
 .../drill/exec/ref/values/ComparableValue.java  |  38 --
 .../drill/exec/ref/values/ContainerValue.java   |  25 -
 .../apache/drill/exec/ref/values/DataValue.java |  45 --
 .../drill/exec/ref/values/DataValueSet.java     |  80 ---
 .../drill/exec/ref/values/NumericValue.java     | 175 ------
 .../drill/exec/ref/values/ScalarValues.java     | 560 -------------------
 .../drill/exec/ref/values/SimpleArrayValue.java | 147 -----
 .../drill/exec/ref/values/SimpleMapValue.java   | 130 -----
 .../drill/exec/ref/values/StringValue.java      |  22 -
 .../drill/exec/ref/values/ValueReader.java      |  62 --
 .../drill/exec/ref/values/ValueUtils.java       |  80 ---
 exec/ref/src/main/resources/drill-module.conf   |   4 -
 exec/ref/src/main/resources/logback-test.xml    |  43 --
 .../apache/drill/exec/ref/RSERegistryTest.java  |  40 --
 .../apache/drill/exec/ref/RunSimplePlan.java    |  77 ---
 .../org/apache/drill/exec/ref/TestUtils.java    | 122 ----
 .../exec/ref/rops/CollapsingAggregateTest.java  |  51 --
 .../drill/exec/ref/rops/ConstantROPTest.java    | 111 ----
 .../apache/drill/exec/ref/rops/JoinROPTest.java |  39 --
 .../drill/exec/ref/rops/LimitROPTest.java       |  84 ---
 .../drill/exec/ref/rops/OrderROPTest.java       |  61 --
 .../drill/exec/ref/rops/UnionROPTest.java       |  63 ---
 .../drill/exec/ref/rops/WindowFrameROPTest.java | 259 ---------
 exec/ref/src/test/resources/collapse/test1.json |  73 ---
 exec/ref/src/test/resources/constant.json       |   4 -
 exec/ref/src/test/resources/constant2.json      |  42 --
 exec/ref/src/test/resources/departments.json    |  16 -
 exec/ref/src/test/resources/donuts.json         | 132 -----
 exec/ref/src/test/resources/employees.json      |  23 -
 .../src/test/resources/join/departments.json    |  16 -
 exec/ref/src/test/resources/join/employees.json |  24 -
 exec/ref/src/test/resources/join/full_join.json |  72 ---
 exec/ref/src/test/resources/join/left_join.json |  71 ---
 .../src/test/resources/join/simple_join.json    |  71 ---
 exec/ref/src/test/resources/logback.xml         |  56 --
 .../src/test/resources/order/nulls-first.json   |  79 ---
 .../src/test/resources/order/nulls-last.json    |  79 ---
 exec/ref/src/test/resources/simple_join.json    |  60 --
 exec/ref/src/test/resources/simple_plan.json    |  94 ----
 .../test/resources/simple_plan_flattened.json   |  54 --
 exec/ref/src/test/resources/union/distinct.json |  82 ---
 .../src/test/resources/union/nondistinct.json   |  82 ---
 pom.xml                                         |  26 +-
 protocol/src/main/protobuf/User.proto           |   8 +
 sqlparser/pom.xml                               |  26 +-
 .../drill/jdbc/AvaticaDrillSqlAccessor.java     | 214 +++++++
 .../java/org/apache/drill/jdbc/BasicList.java   | 136 +++++
 .../org/apache/drill/jdbc/ConnectionConfig.java |  41 ++
 .../apache/drill/jdbc/DrillAccessorList.java    |  58 ++
 .../drill/jdbc/DrillColumnMetaDataList.java     |  81 +++
 .../org/apache/drill/jdbc/DrillConnection.java  |  41 ++
 .../apache/drill/jdbc/DrillConnectionImpl.java  | 166 ++++++
 .../java/org/apache/drill/jdbc/DrillCursor.java | 127 +++++
 .../apache/drill/jdbc/DrillDriverVersion.java   |  42 --
 .../org/apache/drill/jdbc/DrillFactory.java     |  57 ++
 .../org/apache/drill/jdbc/DrillHandler.java     | 190 +------
 .../apache/drill/jdbc/DrillJdbc40Factory.java   |  29 +
 .../apache/drill/jdbc/DrillJdbc41Factory.java   | 186 ++++++
 .../apache/drill/jdbc/DrillPrepareResult.java   |  52 ++
 .../drill/jdbc/DrillPreparedStatement.java      |  50 ++
 .../apache/drill/jdbc/DrillRemoteStatement.java |  22 +
 .../org/apache/drill/jdbc/DrillResultSet.java   | 196 +++++++
 .../org/apache/drill/jdbc/DrillStatement.java   |  39 ++
 .../drill/jdbc/DrillStatementRegistry.java      |  28 +
 .../java/org/apache/drill/jdbc/DrillTable.java  | 225 --------
 .../main/java/org/apache/drill/jdbc/Driver.java |  72 ++-
 .../drill/jdbc/GlobalServiceSetReference.java   |  29 +
 .../java/org/apache/drill/jdbc/MetaImpl.java    | 180 ++++++
 .../java/org/apache/drill/jdbc/RefDriver.java   |  71 ---
 .../apache/drill/jdbc/SchemaChangeListener.java |  24 +
 .../apache/drill/jdbc/SqlTimeoutException.java  |  34 ++
 .../org/apache/drill/jdbc/StorageEngines.java   |  74 ---
 .../org/apache/drill/jdbc/package-info.java     |  22 +
 .../apache/drill/optiq/DrillAggregateRel.java   | 119 ----
 .../apache/drill/optiq/DrillAggregateRule.java  |  53 --
 .../org/apache/drill/optiq/DrillFilterRel.java  |  60 --
 .../org/apache/drill/optiq/DrillFilterRule.java |  42 --
 .../apache/drill/optiq/DrillImplementor.java    | 146 -----
 .../org/apache/drill/optiq/DrillJoinRel.java    | 158 ------
 .../org/apache/drill/optiq/DrillJoinRule.java   |  57 --
 .../org/apache/drill/optiq/DrillLimitRel.java   |  60 --
 .../org/apache/drill/optiq/DrillLimitRule.java  |  59 --
 .../java/org/apache/drill/optiq/DrillOptiq.java | 180 ------
 .../apache/drill/optiq/DrillPrepareImpl.java    |  56 --
 .../org/apache/drill/optiq/DrillProjectRel.java |  83 ---
 .../apache/drill/optiq/DrillProjectRule.java    |  46 --
 .../java/org/apache/drill/optiq/DrillRel.java   |  32 --
 .../java/org/apache/drill/optiq/DrillScan.java  |  60 --
 .../org/apache/drill/optiq/DrillSortRel.java    |  98 ----
 .../org/apache/drill/optiq/DrillSortRule.java   |  51 --
 .../org/apache/drill/optiq/DrillUnionRel.java   |  75 ---
 .../org/apache/drill/optiq/DrillUnionRule.java  |  48 --
 .../org/apache/drill/optiq/DrillValuesRel.java  |  53 --
 .../org/apache/drill/optiq/DrillValuesRule.java |  39 --
 .../org/apache/drill/optiq/EnumerableDrill.java | 271 ---------
 .../drill/optiq/EnumerableDrillFullEngine.java  |  87 ---
 .../apache/drill/optiq/EnumerableDrillRel.java  | 130 -----
 .../apache/drill/optiq/EnumerableDrillRule.java |  53 --
 .../drill/sql/client/full/BatchListener.java    |  79 ---
 .../drill/sql/client/full/BatchLoaderMap.java   | 233 --------
 .../drill/sql/client/full/DrillFullImpl.java    |  76 ---
 .../sql/client/full/DrillMutableSchema.java     |  91 ---
 .../drill/sql/client/full/FileSystemSchema.java | 154 -----
 .../drill/sql/client/full/JsonHelper.java       |  57 --
 .../drill/sql/client/full/ResultEnumerator.java |  72 ---
 .../drill/sql/client/ref/DrillRefImpl.java      | 271 ---------
 .../src/main/resources/storage-engines.json     |  29 -
 .../apache/drill/jdbc/test/FullEngineTest.java  |  87 ---
 .../org/apache/drill/jdbc/test/JdbcAssert.java  |  11 +-
 .../org/apache/drill/jdbc/test/JdbcTest.java    |  50 +-
 .../apache/drill/jdbc/test/TestJdbcQuery.java   | 108 ++++
 311 files changed, 6944 insertions(+), 14542 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/pom.xml
----------------------------------------------------------------------
diff --git a/common/pom.xml b/common/pom.xml
index 7b3c697..d76f7a1 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -36,6 +36,19 @@
     </dependency>
 
     <dependency>
+      <!-- add as provided scope so that we can compile TestTools.  Should only be ever used in a test scenario where someone else is bringing JUnit in. -->
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${dep.junit.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>net.hydromatic</groupId>
+      <artifactId>optiq-core</artifactId>
+    </dependency>
+
+
+    <dependency>
       <groupId>com.google.protobuf</groupId>
       <artifactId>protobuf-java</artifactId>
       <version>2.5.0</version>
@@ -68,7 +81,7 @@
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-annotations</artifactId>
-      <version>2.1.1</version>
+      <version>2.2.0</version>
     </dependency>
     <dependency>
       <groupId>org.hibernate</groupId>
@@ -84,7 +97,7 @@
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-databind</artifactId>
-      <version>2.1.1</version>
+      <version>2.2.0</version>
     </dependency>
     <dependency>
       <groupId>org.antlr</groupId>
@@ -99,12 +112,12 @@
   <build>
     <plugins>
       <plugin>
-          <artifactId>maven-surefire-plugin</artifactId>
-          <version>2.15</version>
-          <configuration>
-            <useSystemClassLoader>false</useSystemClassLoader>
-          </configuration>
-      </plugin>    
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.15</version>
+        <configuration>
+          <useSystemClassLoader>false</useSystemClassLoader>
+        </configuration>
+      </plugin>
       <plugin>
         <artifactId>maven-jar-plugin</artifactId>
         <executions>
@@ -131,7 +144,7 @@
           </execution>
         </executions>
       </plugin>
-	 
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
@@ -144,13 +157,13 @@
             </goals>
             <configuration>
               <artifactSet>
-                 <includes>
-                    <include>com.google.protobuf:protobuf-java</include>                     
-                 </includes>                 
+                <includes>
+                  <include>com.google.protobuf:protobuf-java</include>
+                </includes>
               </artifactSet>
               <shadedArtifactAttached>true</shadedArtifactAttached>
               <shadedClassifierName>rebuffed</shadedClassifierName>
-             
+
               <relocations>
                 <relocation>
                   <pattern>com.google.protobuf</pattern>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/JSONOptions.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/JSONOptions.java b/common/src/main/java/org/apache/drill/common/JSONOptions.java
index 23de124..c1f9a85 100644
--- a/common/src/main/java/org/apache/drill/common/JSONOptions.java
+++ b/common/src/main/java/org/apache/drill/common/JSONOptions.java
@@ -18,12 +18,8 @@
 package org.apache.drill.common;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
+import java.lang.reflect.ParameterizedType;
 
-import com.fasterxml.jackson.core.*;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.drill.common.JSONOptions.De;
 import org.apache.drill.common.JSONOptions.Se;
 import org.apache.drill.common.config.DrillConfig;
@@ -31,8 +27,16 @@ import org.apache.drill.common.exceptions.LogicalPlanParsingException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonLocation;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.TreeNode;
+import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.DeserializationContext;
 import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializerProvider;
 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -47,14 +51,28 @@ public class JSONOptions {
   
   private JsonNode root;
   private JsonLocation location;
+  private Object opaque;
+  
+  public JSONOptions(Object opaque){
+    this.opaque = opaque;
+  }
   
   public JSONOptions(JsonNode n, JsonLocation location){
     this.root = n;
     this.location = location;
   }
   
+  @SuppressWarnings("unchecked")
   public <T> T getWith(DrillConfig config, Class<T> c){
     try {
+      if(opaque != null){
+        if (opaque.getClass().equals(c)){
+          return (T) opaque;
+        }else{
+          throw new IllegalArgumentException(String.format("Attmpted to retrieve a option with type of %s.  However, the JSON options carried an opaque value of type %s.", c.getName(), opaque.getClass().getName()));
+        }
+      }
+      
       //logger.debug("Read tree {}", root);
       return config.getMapper().treeToValue(root, c);
     } catch (JsonProcessingException e) {
@@ -63,11 +81,20 @@ public class JSONOptions {
   }
 
   public <T> T getListWith(DrillConfig config, TypeReference<T> t) throws IOException {
-      ObjectMapper mapper = config.getMapper();
-      return mapper.treeAsTokens(root).readValueAs(t);
+    return getListWith(config.getMapper(), t);
   }
 
+  @SuppressWarnings("unchecked")
   public <T> T getListWith(ObjectMapper mapper, TypeReference<T> t) throws IOException {
+    if(opaque != null){
+      ParameterizedType pt = (ParameterizedType) t.getType();
+      if ( pt.getRawType().equals(opaque.getClass())){
+        return (T) opaque;
+      }else{
+        throw new IOException(String.format("Attmpted to retrieve a list with type of %s.  However, the JSON options carried an opaque value of type %s.", t.getType(), opaque.getClass().getName()));
+      }
+    }
+    if(root == null) return null;
     return mapper.treeAsTokens(root).readValueAs(t);
   }
   
@@ -111,7 +138,12 @@ public class JSONOptions {
     @Override
     public void serialize(JSONOptions value, JsonGenerator jgen, SerializerProvider provider) throws IOException,
         JsonGenerationException {
-      jgen.writeTree(value.root);
+      if(value.opaque != null){
+        jgen.writeObject(value.opaque);
+      }else{
+        jgen.writeTree(value.root);  
+      }
+      
     }
 
   }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/defs/OrderDef.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/defs/OrderDef.java b/common/src/main/java/org/apache/drill/common/defs/OrderDef.java
deleted file mode 100644
index e33de94..0000000
--- a/common/src/main/java/org/apache/drill/common/defs/OrderDef.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.drill.common.defs;
-
-import org.apache.drill.common.expression.LogicalExpression;
-import org.apache.drill.common.logical.data.Order.Direction;
-import org.apache.drill.common.logical.data.Order.Ordering;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class OrderDef {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(OrderDef.class);
-
-  private final Direction direction;
-  private final LogicalExpression expr;
-
-  @JsonCreator
-  public OrderDef(@JsonProperty("order") Direction direction, @JsonProperty("expr") LogicalExpression expr) {
-    this.expr = expr;
-    // default to ascending unless desc is provided.
-    this.direction = direction == null ? Direction.ASC : direction;
-  }
-  
-  @JsonIgnore
-  public Direction getDirection() {
-    return direction;
-  }
-
-  public LogicalExpression getExpr() {
-    return expr;
-  }
-
-  public String getOrder() {
-    return direction.description;
-  }
-
-  public static OrderDef create(Ordering o){
-    return new OrderDef(o.getDirection(), o.getExpr());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/defs/PartitionDef.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/defs/PartitionDef.java b/common/src/main/java/org/apache/drill/common/defs/PartitionDef.java
deleted file mode 100644
index f763fd2..0000000
--- a/common/src/main/java/org/apache/drill/common/defs/PartitionDef.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.drill.common.defs;
-
-import org.apache.drill.common.expression.LogicalExpression;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class PartitionDef {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PartitionDef.class);
-
-  private final PartitionType partitionType;
-  private final LogicalExpression expr;
-  private final LogicalExpression[] starts;
-  
-  @JsonCreator
-  public PartitionDef(@JsonProperty("mode") PartitionType partitionType, @JsonProperty("expr") LogicalExpression expr, @JsonProperty("starts") LogicalExpression[] starts) {
-    this.partitionType = partitionType;
-    this.expr = expr;
-    this.starts = starts;
-  }
-
-  @JsonProperty("mode")
-  public PartitionType getPartitionType() {
-    return partitionType;
-  }
-
-  @JsonProperty("expr")
-  public LogicalExpression getExpr() {
-    return expr;
-  }
-
-  @JsonProperty("starts")
-  public LogicalExpression[] getStarts() {
-    return starts;
-  }
-  
-
-  public static enum PartitionType{ 
-    DUPLICATE, RANDOM, HASH, RANGE;
-  };
-}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/expression/FieldReference.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/expression/FieldReference.java b/common/src/main/java/org/apache/drill/common/expression/FieldReference.java
index f01d525..358a865 100644
--- a/common/src/main/java/org/apache/drill/common/expression/FieldReference.java
+++ b/common/src/main/java/org/apache/drill/common/expression/FieldReference.java
@@ -43,6 +43,9 @@ public class FieldReference extends SchemaPath {
     super(sp);
   }
   
+  public FieldReference(CharSequence value){
+    super(value, ExpressionPosition.UNKNOWN);
+  }
   
   public FieldReference(CharSequence value, ExpressionPosition pos) {
     super(value, pos);

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/expression/FunctionRegistry.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/expression/FunctionRegistry.java b/common/src/main/java/org/apache/drill/common/expression/FunctionRegistry.java
index 8ffc07a..7cb386a 100644
--- a/common/src/main/java/org/apache/drill/common/expression/FunctionRegistry.java
+++ b/common/src/main/java/org/apache/drill/common/expression/FunctionRegistry.java
@@ -87,6 +87,9 @@ public class FunctionRegistry {
     return new FunctionCall(castFuncDef, newArgs, ep);
   }
 
+  public LogicalExpression createExpression(String functionName, List<LogicalExpression> args){
+    return createExpression(functionName, ExpressionPosition.UNKNOWN, args);
+  }
   
   public LogicalExpression createExpression(String functionName, ExpressionPosition ep, List<LogicalExpression> args){
     FunctionDefinition d = funcMap.get(functionName);

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java b/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java
index 31bac80..7c2dce6 100644
--- a/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java
+++ b/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java
@@ -112,7 +112,7 @@ public class SchemaPath extends LogicalExpressionBase {
     return visitor.visitSchemaPath(this, value);
   }
 
-  public SchemaPath getChild(String[] childPaths){
+  public SchemaPath getChild(String... childPaths){
     return new SchemaPath(this, childPaths);
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java b/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java
index 9137356..49f3773 100644
--- a/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java
+++ b/common/src/main/java/org/apache/drill/common/expression/ValueExpressions.java
@@ -29,6 +29,30 @@ import com.google.common.collect.Iterators;
 
 public class ValueExpressions {
 
+  public static LogicalExpression getBigInt(long l){
+    return new LongExpression(l);
+  }
+  
+  public static LogicalExpression getInt(int i){
+    return new LongExpression(i);
+  }
+  
+  public static LogicalExpression getFloat8(double d){
+    return new DoubleExpression(d, ExpressionPosition.UNKNOWN);
+  }
+  public static LogicalExpression getFloat4(float f){
+    return new DoubleExpression(f, ExpressionPosition.UNKNOWN);
+  }
+  
+  public static LogicalExpression getBit(boolean b){
+    return new BooleanExpression(Boolean.toString(b), ExpressionPosition.UNKNOWN);
+  }
+  
+  public static LogicalExpression getChar(String s){
+    return new QuotedString(s, ExpressionPosition.UNKNOWN);
+  }
+  
+
   public static LogicalExpression getNumericExpression(String s, ExpressionPosition ep) {
     try {
       long l = Long.parseLong(s);
@@ -74,6 +98,7 @@ public class ValueExpressions {
       super(value, pos);
     }
 
+    
     @Override
     protected Boolean parseValue(String s) {
       return Boolean.parseBoolean(s);
@@ -132,7 +157,11 @@ public class ValueExpressions {
 
     private long l;
 
-    public LongExpression(long l, ExpressionPosition pos) {
+    public LongExpression(long l) {
+      this(l, ExpressionPosition.UNKNOWN);
+    }
+    
+      public LongExpression(long l, ExpressionPosition pos) {
       super(pos);
       this.l = l;
     }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/LogicalPlan.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/LogicalPlan.java b/common/src/main/java/org/apache/drill/common/logical/LogicalPlan.java
index 8be44e9..a9db251 100644
--- a/common/src/main/java/org/apache/drill/common/logical/LogicalPlan.java
+++ b/common/src/main/java/org/apache/drill/common/logical/LogicalPlan.java
@@ -46,7 +46,8 @@ public class LogicalPlan {
   private final PlanProperties properties;
   private final Map<String, StorageEngineConfig> storageEngineMap;
   private final Graph<LogicalOperator, SinkOperator, SourceOperator> graph;
-
+  
+  
   @JsonCreator
   public LogicalPlan(@JsonProperty("head") PlanProperties head,
       @JsonProperty("storage") Map<String, StorageEngineConfig> storageEngineMap,
@@ -84,6 +85,15 @@ public class LogicalPlan {
     return config.getMapper().writeValueAsString(this);
   }
 
+  public String toJsonStringSafe(DrillConfig config){
+    try{
+      return toJsonString(config);
+    }catch(JsonProcessingException e){
+      logger.error("Failure while trying to get JSON representation of plan.", e);
+      return "Unable to generate plan.";
+    }
+  }
+
   /** Parses a logical plan. */
   public static LogicalPlan parse(DrillConfig config, String planString) {
     ObjectMapper mapper = config.getMapper();

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/LogicalPlanBuilder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/LogicalPlanBuilder.java b/common/src/main/java/org/apache/drill/common/logical/LogicalPlanBuilder.java
index 675a5c8..369cd58 100644
--- a/common/src/main/java/org/apache/drill/common/logical/LogicalPlanBuilder.java
+++ b/common/src/main/java/org/apache/drill/common/logical/LogicalPlanBuilder.java
@@ -17,9 +17,12 @@
  ******************************************************************************/
 package org.apache.drill.common.logical;
 
+import org.apache.drill.common.logical.PlanProperties.Generator.ResultMode;
+import org.apache.drill.common.logical.PlanProperties.PlanType;
+import org.apache.drill.common.logical.data.LogicalOperator;
+
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
-import org.apache.drill.common.logical.data.LogicalOperator;
 
 /**
  * A programmatic builder for logical plans.
@@ -33,6 +36,12 @@ public class LogicalPlanBuilder {
     this.planProperties = planProperties;
     return this;
   }
+  
+  public LogicalPlanBuilder planProperties(PlanType type, int version, String generatorType, String generatorInfo, ResultMode mode){
+    this.planProperties = PlanProperties.builder().generator(generatorType, generatorInfo).type(type).version(version).resultMode(mode).build();
+    return this;
+  }
+  
   public LogicalPlanBuilder addStorageEngine(String name, StorageEngineConfig config) {
     this.storageEngines.put(name, config);
     return this;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/PlanProperties.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/PlanProperties.java b/common/src/main/java/org/apache/drill/common/logical/PlanProperties.java
index 5980bf8..606f2df 100644
--- a/common/src/main/java/org/apache/drill/common/logical/PlanProperties.java
+++ b/common/src/main/java/org/apache/drill/common/logical/PlanProperties.java
@@ -17,6 +17,8 @@
  ******************************************************************************/
 package org.apache.drill.common.logical;
 
+import org.apache.drill.common.logical.PlanProperties.Generator.ResultMode;
+
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -30,11 +32,16 @@ public class PlanProperties {
   public PlanType type;
   public int version;
 	public Generator generator;
+	public ResultMode resultMode;
 
-	@JsonInclude(Include.NON_NULL)
+//	@JsonInclude(Include.NON_NULL)
 	public static class Generator{
 		public String type;
 		public String info;
+	  
+		public static enum ResultMode{
+	    EXEC, LOGICAL, PHYSICAL;
+	  }
 
     private Generator(@JsonProperty("type") String type, @JsonProperty("info") String info) {
       this.type = type;
@@ -44,10 +51,13 @@ public class PlanProperties {
 
   private PlanProperties(@JsonProperty("version") int version,
                          @JsonProperty("generator") Generator generator,
-                         @JsonProperty("type") PlanType type) {
+                         @JsonProperty("type") PlanType type,
+                         @JsonProperty("mode") ResultMode resultMode
+                         ) {
     this.version = version;
     this.generator = generator;
     this.type = type;
+    this.resultMode = resultMode == null ? ResultMode.EXEC : resultMode;
   }
 
   public static PlanPropertiesBuilder builder() {
@@ -58,6 +68,7 @@ public class PlanProperties {
     private int version;
     private Generator generator;
     private PlanType type;
+    private ResultMode mode = ResultMode.EXEC;
 
     public PlanPropertiesBuilder type(PlanType type) {
       this.type = type;
@@ -73,6 +84,11 @@ public class PlanProperties {
       this.generator = new Generator(type, info);
       return this;
     }
+    
+    public PlanPropertiesBuilder resultMode(ResultMode mode){
+      this.mode = mode;
+      return this;
+    }
 
     public PlanPropertiesBuilder generator(Generator generator) {
       this.generator = generator;
@@ -80,7 +96,7 @@ public class PlanProperties {
     }
 
     public PlanProperties build() {
-      return new PlanProperties(version, generator, type);
+      return new PlanProperties(version, generator, type, mode);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/AbstractBuilder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/AbstractBuilder.java b/common/src/main/java/org/apache/drill/common/logical/data/AbstractBuilder.java
new file mode 100644
index 0000000..69cb4eb
--- /dev/null
+++ b/common/src/main/java/org/apache/drill/common/logical/data/AbstractBuilder.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.common.logical.data;
+
+import java.util.List;
+
+import org.apache.drill.common.expression.LogicalExpression;
+
+public abstract class AbstractBuilder<T extends LogicalOperator> {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractBuilder.class);
+  
+  public abstract T build();
+  
+  protected LogicalExpression[] aL(List<LogicalExpression> exprs){
+    return exprs.toArray(new LogicalExpression[exprs.size()]);
+  }
+
+  protected NamedExpression[] aN(List<NamedExpression> exprs){
+    return exprs.toArray(new NamedExpression[exprs.size()]);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/AbstractSingleBuilder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/AbstractSingleBuilder.java b/common/src/main/java/org/apache/drill/common/logical/data/AbstractSingleBuilder.java
new file mode 100644
index 0000000..e733fdd
--- /dev/null
+++ b/common/src/main/java/org/apache/drill/common/logical/data/AbstractSingleBuilder.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.common.logical.data;
+
+import com.google.common.base.Preconditions;
+
+public abstract class AbstractSingleBuilder<T extends SingleInputOperator, X extends AbstractSingleBuilder<T, X>> extends AbstractBuilder<T> {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractSingleBuilder.class);
+  
+  private LogicalOperator input;
+
+  public final T build(){
+    Preconditions.checkNotNull(input);
+    T out = internalBuild();
+    out.setInput(input);
+    return out;
+  }
+  
+  public X setInput(LogicalOperator input){
+    this.input = input;
+    return (X) this;
+  }
+  
+  public abstract T internalBuild();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/GroupingAggregate.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/GroupingAggregate.java b/common/src/main/java/org/apache/drill/common/logical/data/GroupingAggregate.java
new file mode 100644
index 0000000..4aabfba
--- /dev/null
+++ b/common/src/main/java/org/apache/drill/common/logical/data/GroupingAggregate.java
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.common.logical.data;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.drill.common.expression.FieldReference;
+import org.apache.drill.common.expression.LogicalExpression;
+import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
+
+@JsonTypeName("groupingaggregate")
+public class GroupingAggregate extends SingleInputOperator{
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(GroupingAggregate.class);
+  
+  private final NamedExpression[] keys;
+  private final NamedExpression[] exprs;
+  
+  public GroupingAggregate(@JsonProperty("keys") NamedExpression[] keys, @JsonProperty("exprs") NamedExpression[] exprs) {
+    super();
+    this.keys = keys;
+    this.exprs = exprs;
+  }
+  
+  @Override
+  public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
+      return logicalVisitor.visitGroupingAggregate(this, value);
+  }
+
+  @Override
+  public Iterator<LogicalOperator> iterator() {
+    return Iterators.singletonIterator(getInput());
+  }
+
+  public static Builder builder(){
+    return new Builder();
+  }
+  
+  public NamedExpression[] getKeys(){
+    return keys;
+  }
+  
+  public NamedExpression[] getExprs(){
+    return exprs;
+  }
+  
+  public static class Builder extends AbstractSingleBuilder<GroupingAggregate, Builder>{
+    private List<NamedExpression> keys = Lists.newArrayList();
+    private List<NamedExpression> exprs = Lists.newArrayList();
+    
+    public Builder addKey(FieldReference ref, LogicalExpression expr){
+      keys.add(new NamedExpression(expr, ref));
+      return this;
+    }
+
+    public Builder addKey(NamedExpression expr){
+      keys.add(expr);
+      return this;
+    }
+    
+    public Builder addExpr(NamedExpression expr){
+      exprs.add(expr);
+      return this;
+    }
+    
+    public Builder addExpr(FieldReference ref, LogicalExpression expr){
+      exprs.add(new NamedExpression(expr, ref));
+      return this;
+    }
+
+    public GroupingAggregate internalBuild(){
+      GroupingAggregate ga =  new GroupingAggregate(aN(keys), aN(exprs));
+      return ga;
+    }
+    
+  }
+  
+  
+     
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/Join.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/Join.java b/common/src/main/java/org/apache/drill/common/logical/data/Join.java
index 06f276b..3e68b09 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/Join.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/Join.java
@@ -17,47 +17,55 @@
  */
 package org.apache.drill.common.logical.data;
 
-import com.google.common.collect.Iterators;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.drill.common.exceptions.ExpressionParsingException;
+import org.apache.drill.common.expression.LogicalExpression;
+import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
+import org.eigenbase.rel.JoinRelType;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
 
 @JsonTypeName("join")
 public class Join extends LogicalOperatorBase {
   private final LogicalOperator left;
   private final LogicalOperator right;
-  private final JoinType type;
+  private final JoinRelType type;
   private final JoinCondition[] conditions;
 
-  public static enum JoinType{
-    LEFT, INNER, OUTER, RIGHT;
-    
-    public static JoinType resolve(String val){
-      for(JoinType jt : JoinType.values()){
-        if(jt.name().equalsIgnoreCase(val)) return jt;
-      }
-      throw new ExpressionParsingException(String.format("Unable to determine join type for value '%s'.", val));
+  public static JoinRelType resolve(String val){
+    for (JoinRelType jt : JoinRelType.values()) {
+      if (jt.name().equalsIgnoreCase(val))
+        return jt;
     }
+    throw new ExpressionParsingException(String.format("Unable to determine join type for value '%s'.", val));
   }
   
   @JsonCreator
-  public Join(@JsonProperty("left") LogicalOperator left, @JsonProperty("right") LogicalOperator right, @JsonProperty("conditions") JoinCondition[] conditions, @JsonProperty("type") String type) {
+  public Join(@JsonProperty("left") LogicalOperator left, @JsonProperty("right") LogicalOperator right,
+      @JsonProperty("conditions") JoinCondition[] conditions, @JsonProperty("type") String type) {
+    this(left, right, conditions, resolve(type));
+  }
+
+  
+  public Join(LogicalOperator left, @JsonProperty("right") LogicalOperator right, JoinCondition[] conditions, JoinRelType type) {
     super();
     this.conditions = conditions;
     this.left = left;
     this.right = right;
     left.registerAsSubscriber(this);
     right.registerAsSubscriber(this);
-    this.type = JoinType.resolve(type);
+    this.type = type;
 
   }
-
+  
   public LogicalOperator getLeft() {
     return left;
   }
@@ -71,21 +79,61 @@ public class Join extends LogicalOperatorBase {
   }
 
   @JsonIgnore
-  public JoinType getJointType(){
+  public JoinRelType getJoinType() {
     return type;
   }
-  
-  public String getType(){
+
+  public String getType() {
     return type.name();
   }
 
-    @Override
-    public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
-        return logicalVisitor.visitJoin(this, value);
-    }
+  @Override
+  public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
+    return logicalVisitor.visitJoin(this, value);
+  }
 
+  @Override
+  public Iterator<LogicalOperator> iterator() {
+    return Iterators.forArray(getLeft(), getRight());
+  }
+  
+  public static Builder builder(){
+    return new Builder();
+  }
+  
+  public static class Builder extends AbstractBuilder<Join>{
+    private LogicalOperator left;
+    private LogicalOperator right;
+    private JoinRelType type;
+    private List<JoinCondition> conditions = Lists.newArrayList();
+    
+    public Builder type(JoinRelType type){
+      this.type = type;
+      return this;
+    }
+    
+    public Builder left(LogicalOperator left){
+      this.left = left;
+      return this;
+    }
+    public Builder right(LogicalOperator right){
+      this.right = right;
+      return this;
+    }
+    
+    public Builder addCondition(String relationship, LogicalExpression left, LogicalExpression right){
+      conditions.add(new JoinCondition(relationship, left, right));
+      return this;
+    }
+    
+    
     @Override
-    public Iterator<LogicalOperator> iterator() {
-        return Iterators.forArray(getLeft(), getRight());
+    public Join build() {
+      Preconditions.checkNotNull(left);
+      Preconditions.checkNotNull(right);
+      Preconditions.checkNotNull(type);
+      return new Join(left, right, conditions.toArray(new JoinCondition[conditions.size()]), type);
     }
+    
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/Order.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/Order.java b/common/src/main/java/org/apache/drill/common/logical/data/Order.java
index 7b77218..3c864b0 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/Order.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/Order.java
@@ -17,17 +17,22 @@
  */
 package org.apache.drill.common.logical.data;
 
-import com.google.common.collect.Iterators;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.drill.common.expression.FieldReference;
 import org.apache.drill.common.expression.LogicalExpression;
+import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
+import org.eigenbase.rel.RelFieldCollation;
+import org.eigenbase.rel.RelFieldCollation.Direction;
+import org.eigenbase.rel.RelFieldCollation.NullDirection;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
 
 @JsonTypeName("order")
 public class Order extends SingleInputOperator {
@@ -62,16 +67,25 @@ public class Order extends SingleInputOperator {
 
     public static class Ordering {
 
-    private final Direction direction;
+    private final RelFieldCollation.Direction direction;
     private final LogicalExpression expr;
-    private final NullCollation nulls;
+    private final RelFieldCollation.NullDirection nulls;
     
     @JsonCreator
-    public Ordering(@JsonProperty("order") String strOrder, @JsonProperty("expr") LogicalExpression expr, @JsonProperty("nullCollation") String nullCollation) {
+    public Ordering(@JsonProperty("order") String strOrder, @JsonProperty("expr") LogicalExpression expr, @JsonProperty("nullDirection") String nullCollation) {
       this.expr = expr;
-      this.nulls = NullCollation.NULLS_LAST.description.equals(nullCollation) ? NullCollation.NULLS_LAST :  NullCollation.NULLS_FIRST; // default first
-      this.direction = Direction.DESC.description.equalsIgnoreCase(strOrder) ? Direction.DESC : Direction.ASC; // default asc
-                                                                                                     
+      this.nulls = NullDirection.LAST.name().equalsIgnoreCase(nullCollation) ? NullDirection.LAST :  NullDirection.FIRST; // default first
+      this.direction = Order.getDirectionFromString(strOrder);
+    }
+
+    public Ordering(Direction direction, LogicalExpression e, NullDirection nullCollation) {
+      this.expr = e;
+      this.nulls = nullCollation;
+      this.direction = direction;
+    }
+    
+    public Ordering(Direction direction, LogicalExpression e) {
+      this(direction, e, NullDirection.FIRST);
     }
 
     @JsonIgnore
@@ -84,34 +98,52 @@ public class Order extends SingleInputOperator {
     }
 
     public String getOrder() {
-      return direction.description;
+      
+      switch(direction){
+      case Descending: return "DESC";
+      default: return "ASC";
+      }
     }
 
-    public NullCollation getNullCollation() {
+    public NullDirection getNullDirection() {
       return nulls;
     }
     
     
 
   }
-  public static enum NullCollation {
-    NULLS_FIRST("first"), NULLS_LAST("last");
+  
+  public static Builder builder(){
+    return new Builder();
+  }
+  
+  public static class Builder extends AbstractSingleBuilder<Order, Builder>{
+    private List<Ordering> orderings = Lists.newArrayList();
+    private FieldReference within;
     
-    public final String description;
-
-    NullCollation(String d) {
-      description = d;
+    public Builder setWithin(FieldReference within){
+      this.within = within;
+      return this;
+    }
+    
+    public Builder addOrdering(Direction direction, LogicalExpression e, NullDirection collation){
+      orderings.add(new Ordering(direction, e, collation));
+      return this;
     }
-  }
-
-  public static enum Direction {
-    ASC("ASC"), DESC("DESC");
-    public final String description;
 
-    Direction(String d) {
-      description = d;
+    @Override
+    public Order internalBuild() {
+      return new Order(within, orderings.toArray(new Ordering[orderings.size()]));
     }
+    
+    
   }
   
+  public static Direction getDirectionFromString(String direction){
+    return "DESC".equalsIgnoreCase(direction) ? Direction.Descending : Direction.Ascending;
+  }
   
+  public static String getStringFromDirection(Direction direction){
+    return direction == Direction.Descending ? "DESC" : "ASC";
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/Project.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/Project.java b/common/src/main/java/org/apache/drill/common/logical/data/Project.java
index 5c0716d..645dc32 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/Project.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/Project.java
@@ -17,16 +17,20 @@
  */
 package org.apache.drill.common.logical.data;
 
-import com.google.common.collect.Iterators;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.drill.common.exceptions.ExpressionParsingException;
+import org.apache.drill.common.expression.FieldReference;
+import org.apache.drill.common.expression.LogicalExpression;
 import org.apache.drill.common.expression.PathSegment;
+import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
 
 @JsonTypeName("project")
 public class Project extends SingleInputOperator {
@@ -36,13 +40,18 @@ public class Project extends SingleInputOperator {
   @JsonCreator
   public Project(@JsonProperty("projections") NamedExpression[] selections) {
     this.selections = selections;
-    if(selections == null || selections.length == 0) throw new ExpressionParsingException("Project did not provide any projection selections.  At least one projection must be provided.");
+    if (selections == null || selections.length == 0)
+      throw new ExpressionParsingException(
+          "Project did not provide any projection selections.  At least one projection must be provided.");
     for (int i = 0; i < selections.length; i++) {
       PathSegment segment = selections[i].getRef().getRootSegment();
       CharSequence path = segment.getNameSegment().getPath();
       if (!segment.isNamed() || !path.equals("output"))
-        throw new ExpressionParsingException(String.format(
-            "Outputs for projections always have to start with named path of output. First segment was named '%s' or was named [%s]", path, segment.isNamed()));
+        throw new ExpressionParsingException(
+            String
+                .format(
+                    "Outputs for projections always have to start with named path of output. First segment was named '%s' or was named [%s]",
+                    path, segment.isNamed()));
 
     }
   }
@@ -52,15 +61,33 @@ public class Project extends SingleInputOperator {
     return selections;
   }
 
-    @Override
-    public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
-        return logicalVisitor.visitProject(this, value);
+  @Override
+  public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
+    return logicalVisitor.visitProject(this, value);
+  }
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  public static class Builder extends AbstractSingleBuilder<Project, Builder> {
+
+    private List<NamedExpression> exprs = Lists.newArrayList();
+
+    public Builder addExpr(NamedExpression expr) {
+      exprs.add(expr);
+      return this;
     }
 
-    @Override
-    public Iterator<LogicalOperator> iterator() {
-        return Iterators.singletonIterator(getInput());
+    public Builder addExpr(FieldReference ref, LogicalExpression expr) {
+      exprs.add(new NamedExpression(expr, ref));
+      return this;
     }
 
+    @Override
+    public Project internalBuild() {
+      return new Project(aN(exprs));
+    }
 
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/Scan.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/Scan.java b/common/src/main/java/org/apache/drill/common/logical/data/Scan.java
index 294c0e8..c36c2d1 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/Scan.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/Scan.java
@@ -19,11 +19,11 @@ package org.apache.drill.common.logical.data;
 
 import org.apache.drill.common.JSONOptions;
 import org.apache.drill.common.expression.FieldReference;
+import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
 
 
 @JsonTypeName("scan")
@@ -59,8 +59,34 @@ public class Scan extends SourceOperator{
       return logicalVisitor.visitScan(this, value);
   }
 
-  public static ScanBuilder builder() {
-    return new ScanBuilder();
+  public static Builder builder() {
+    return new Builder();
+  }
+  
+  
+  public static class Builder extends AbstractBuilder<Scan>{
+    private String storageEngine;
+    private JSONOptions selection;
+    private FieldReference outputReference;
+
+    public Builder storageEngine(String storageEngine) {
+      this.storageEngine = storageEngine;
+      return this;
+    }
+
+    public Builder selection(JSONOptions selection) {
+      this.selection = selection;
+      return this;
+    }
+
+    public Builder outputReference(FieldReference outputReference) {
+      this.outputReference = outputReference;
+      return this;
+    }
+
+    public Scan build() {
+      return new Scan(storageEngine, selection, outputReference);
+    }
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/ScanBuilder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/ScanBuilder.java b/common/src/main/java/org/apache/drill/common/logical/data/ScanBuilder.java
deleted file mode 100644
index 3eaa91f..0000000
--- a/common/src/main/java/org/apache/drill/common/logical/data/ScanBuilder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.drill.common.logical.data;
-
-import org.apache.drill.common.JSONOptions;
-import org.apache.drill.common.expression.FieldReference;
-
-/**
- * Builder for the scan operator
- */
-public class ScanBuilder {
-  private String storageEngine;
-  private JSONOptions selection;
-  private FieldReference outputReference;
-
-  public ScanBuilder storageEngine(String storageEngine) {
-    this.storageEngine = storageEngine;
-    return this;
-  }
-
-  public ScanBuilder selection(JSONOptions selection) {
-    this.selection = selection;
-    return this;
-  }
-
-  public ScanBuilder outputReference(FieldReference outputReference) {
-    this.outputReference = outputReference;
-    return this;
-  }
-
-  public Scan build() {
-    return new Scan(storageEngine, selection, outputReference);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/SingleInputOperator.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/SingleInputOperator.java b/common/src/main/java/org/apache/drill/common/logical/data/SingleInputOperator.java
index 279e13c..0a5015c 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/SingleInputOperator.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/SingleInputOperator.java
@@ -17,9 +17,12 @@
  */
 package org.apache.drill.common.logical.data;
 
+import java.util.Iterator;
+
 import org.apache.drill.common.logical.UnexpectedOperatorType;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.Iterators;
 
 /**
  * SimpleOperator is an operator that has one inputs at most.
@@ -41,6 +44,9 @@ public abstract class SingleInputOperator extends LogicalOperatorBase {
   }
 
   
-  
+  @Override
+  public Iterator<LogicalOperator> iterator() {
+    return Iterators.singletonIterator(input);
+  }
   
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/Store.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/Store.java b/common/src/main/java/org/apache/drill/common/logical/data/Store.java
index 99d1d50..171599f 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/Store.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/Store.java
@@ -17,16 +17,15 @@
  */
 package org.apache.drill.common.logical.data;
 
-import com.google.common.collect.Iterators;
+import java.util.Iterator;
+
 import org.apache.drill.common.JSONOptions;
-import org.apache.drill.common.defs.PartitionDef;
+import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
+import com.google.common.collect.Iterators;
 
 @JsonTypeName("store")
 public class Store extends SinkOperator{
@@ -34,14 +33,12 @@ public class Store extends SinkOperator{
   
   private final String storageEngine;
   private final JSONOptions target;
-  private final PartitionDef partition;
 
   @JsonCreator
-  public Store(@JsonProperty("storageengine") String storageEngine, @JsonProperty("target") JSONOptions target, @JsonProperty("partition") PartitionDef partition) {
+  public Store(@JsonProperty("storageengine") String storageEngine, @JsonProperty("target") JSONOptions target) {
     super();
     this.storageEngine = storageEngine;
     this.target = target;
-    this.partition = partition;
   }
 
   public String getStorageEngine() {
@@ -52,10 +49,6 @@ public class Store extends SinkOperator{
     return target;
   }
 
-  public PartitionDef getPartition() {
-    return partition;
-  }
-
   @Override
   public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
       return logicalVisitor.visitStore(this, value);
@@ -66,8 +59,26 @@ public class Store extends SinkOperator{
       return Iterators.singletonIterator(getInput());
   }
 
-  public static StoreBuilder builder() {
-    return new StoreBuilder();
+  public static Builder builder() {
+    return new Builder();
   }
   
+  public static class Builder extends AbstractSingleBuilder<Store, Builder>{
+    private String storageEngine;
+    private JSONOptions target;
+
+    public Builder storageEngine(String storageEngine) {
+      this.storageEngine = storageEngine;
+      return this;
+    }
+
+    public Builder target(JSONOptions target) {
+      this.target = target;
+      return this;
+    }
+
+    public Store internalBuild() {
+      return new Store(storageEngine, target);
+    }    
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/StoreBuilder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/StoreBuilder.java b/common/src/main/java/org/apache/drill/common/logical/data/StoreBuilder.java
deleted file mode 100644
index 09d20b6..0000000
--- a/common/src/main/java/org/apache/drill/common/logical/data/StoreBuilder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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.drill.common.logical.data;
-
-import org.apache.drill.common.JSONOptions;
-import org.apache.drill.common.defs.PartitionDef;
-
-/**
- * Builder for the scan operator
- */
-public class StoreBuilder {
-  private String storageEngine;
-  private JSONOptions target;
-  private PartitionDef partition;
-
-  public StoreBuilder storageEngine(String storageEngine) {
-    this.storageEngine = storageEngine;
-    return this;
-  }
-
-  public StoreBuilder target(JSONOptions target) {
-    this.target = target;
-    return this;
-  }
-
-  public StoreBuilder partition(PartitionDef partition) {
-    this.partition = partition;
-    return this;
-  }
-
-  public Store build() {
-    return new Store(storageEngine, target, partition);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/Union.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/Union.java b/common/src/main/java/org/apache/drill/common/logical/data/Union.java
index 4db48f8..40c43cd 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/Union.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/Union.java
@@ -17,13 +17,16 @@
  */
 package org.apache.drill.common.logical.data;
 
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
+
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonTypeName;
 import com.google.common.collect.Iterators;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
+import com.google.common.collect.Lists;
 
 @JsonTypeName("union")
 public class Union extends LogicalOperatorBase {
@@ -63,6 +66,29 @@ public class Union extends LogicalOperatorBase {
     }
 
 
-
+    public static Builder builder(){
+      return new Builder();
+    }
+    
+    public static class Builder extends AbstractBuilder<Union>{
+      private List<LogicalOperator> inputs = Lists.newArrayList();
+      private boolean distinct;
+      
+      public Builder addInput(LogicalOperator o){
+        inputs.add(o);
+        return this;
+      }
+      
+      public Builder setDistinct(boolean distinct){
+        this.distinct = distinct;
+        return this;
+      }
+      
+      @Override
+      public Union build() {
+        return new Union(inputs.toArray(new LogicalOperator[inputs.size()]), distinct);
+      }
+      
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/visitors/AbstractLogicalVisitor.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/visitors/AbstractLogicalVisitor.java b/common/src/main/java/org/apache/drill/common/logical/data/visitors/AbstractLogicalVisitor.java
index cd519c6..bb37a14 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/visitors/AbstractLogicalVisitor.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/visitors/AbstractLogicalVisitor.java
@@ -79,6 +79,11 @@ public abstract class AbstractLogicalVisitor<T, X, E extends Throwable> implemen
     }
 
     @Override
+    public T visitGroupingAggregate(GroupingAggregate groupBy, X value) throws E {
+      return visitOp(groupBy, value);
+    }
+    
+    @Override
     public T visitSequence(Sequence sequence, X value) throws E {
         return visitOp(sequence, value);
     }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/logical/data/visitors/LogicalVisitor.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/logical/data/visitors/LogicalVisitor.java b/common/src/main/java/org/apache/drill/common/logical/data/visitors/LogicalVisitor.java
index 8308cc7..f409453 100644
--- a/common/src/main/java/org/apache/drill/common/logical/data/visitors/LogicalVisitor.java
+++ b/common/src/main/java/org/apache/drill/common/logical/data/visitors/LogicalVisitor.java
@@ -18,8 +18,23 @@
 package org.apache.drill.common.logical.data.visitors;
 
 
-import org.apache.drill.common.graph.GraphVisitor;
-import org.apache.drill.common.logical.data.*;
+import org.apache.drill.common.logical.data.CollapsingAggregate;
+import org.apache.drill.common.logical.data.Constant;
+import org.apache.drill.common.logical.data.Filter;
+import org.apache.drill.common.logical.data.Flatten;
+import org.apache.drill.common.logical.data.GroupingAggregate;
+import org.apache.drill.common.logical.data.Join;
+import org.apache.drill.common.logical.data.Limit;
+import org.apache.drill.common.logical.data.Order;
+import org.apache.drill.common.logical.data.Project;
+import org.apache.drill.common.logical.data.RunningAggregate;
+import org.apache.drill.common.logical.data.Scan;
+import org.apache.drill.common.logical.data.Segment;
+import org.apache.drill.common.logical.data.Sequence;
+import org.apache.drill.common.logical.data.Store;
+import org.apache.drill.common.logical.data.Transform;
+import org.apache.drill.common.logical.data.Union;
+import org.apache.drill.common.logical.data.WindowFrame;
 
 /**
  * Visitor class designed to traversal of a operator tree.  Basis for a number of operator manipulations including fragmentation and materialization.
@@ -31,11 +46,10 @@ public interface LogicalVisitor<RETURN, EXTRA, EXCEP extends Throwable> {
     static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LogicalVisitor.class);
 
 
-    //public RETURN visitExchange(Exchange exchange, EXTRA value) throws EXCEP;
     public RETURN visitScan(Scan scan, EXTRA value) throws EXCEP;
     public RETURN visitStore(Store store, EXTRA value) throws EXCEP;
     public RETURN visitCollapsingAggregate(CollapsingAggregate collapsingAggregate, EXTRA value) throws EXCEP;
-
+    public RETURN visitGroupingAggregate(GroupingAggregate groupBy, EXTRA value) throws EXCEP;
     public RETURN visitFilter(Filter filter, EXTRA value) throws EXCEP;
     public RETURN visitFlatten(Flatten flatten, EXTRA value) throws EXCEP;
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/types/Types.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/types/Types.java b/common/src/main/java/org/apache/drill/common/types/Types.java
index efb7bf4..fd8991d 100644
--- a/common/src/main/java/org/apache/drill/common/types/Types.java
+++ b/common/src/main/java/org/apache/drill/common/types/Types.java
@@ -58,6 +58,85 @@ public class Types {
     }
   }
   
+  public static int getSqlType(MajorType type){
+    if(type.getMode() == DataMode.REPEATED) return java.sql.Types.ARRAY;
+    
+    switch(type.getMinorType()){
+    case BIGINT:
+      return java.sql.Types.BIGINT;
+    case BIT:
+      return java.sql.Types.BOOLEAN;
+    case DATE:
+      return java.sql.Types.DATE;
+    case DATETIME:
+      return java.sql.Types.DATE;
+    case DECIMAL12:
+    case DECIMAL16:
+    case DECIMAL4:
+    case DECIMAL8:
+      return java.sql.Types.DECIMAL;
+    case FIXED16CHAR:
+      return java.sql.Types.NCHAR;
+    case FIXEDBINARY:
+      return java.sql.Types.BINARY;
+    case FIXEDCHAR:
+      return java.sql.Types.NCHAR;
+    case FLOAT4:
+      return java.sql.Types.FLOAT;
+    case FLOAT8:
+      return java.sql.Types.DOUBLE;
+    case INT:
+      return java.sql.Types.INTEGER;
+    case MAP:
+      return java.sql.Types.STRUCT;
+    case MONEY:
+      return java.sql.Types.DECIMAL;
+    case NULL:
+    case INTERVAL:
+    case LATE:
+    case REPEATMAP:
+      return java.sql.Types.OTHER;
+    case SMALLINT:
+      return java.sql.Types.SMALLINT;
+    case TIME:
+      return java.sql.Types.TIME;
+    case TIMESTAMP:
+      return java.sql.Types.TIMESTAMP;
+    case TIMETZ:
+      return java.sql.Types.DATE;
+    case TINYINT:
+      return java.sql.Types.TINYINT;
+    case UINT1:
+      return java.sql.Types.TINYINT;
+    case UINT2:
+      return java.sql.Types.SMALLINT;
+    case UINT4:
+      return java.sql.Types.INTEGER;
+    case UINT8:
+      return java.sql.Types.BIGINT;
+    case VAR16CHAR:
+      return java.sql.Types.NVARCHAR;
+    case VARBINARY:
+      return java.sql.Types.VARBINARY;
+    case VARCHAR:
+      return java.sql.Types.NVARCHAR;
+    default:
+      throw new UnsupportedOperationException();
+    }
+  }
+  
+  public static boolean isUnSigned(MajorType type){
+    switch(type.getMinorType()){
+    case UINT1:
+    case UINT2:
+    case UINT4:
+    case UINT8:
+      return true;
+    default:
+      return false;
+    }
+    
+  }
   public static boolean usesHolderForGet(MajorType type){
     if(type.getMode() == REPEATED) return true;
     switch(type.getMinorType()){

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/common/src/main/java/org/apache/drill/common/util/TestTools.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/util/TestTools.java b/common/src/main/java/org/apache/drill/common/util/TestTools.java
new file mode 100644
index 0000000..0a82826
--- /dev/null
+++ b/common/src/main/java/org/apache/drill/common/util/TestTools.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.common.util;
+
+import org.junit.rules.TestName;
+import org.junit.rules.TestRule;
+import org.junit.rules.Timeout;
+
+public class TestTools {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestTools.class);
+  
+  static final boolean IS_DEBUG = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
+
+  
+  public static TestRule getTimeoutRule(){
+    return IS_DEBUG ? new TestName() : new Timeout(10000);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b3460af8/contrib/sqlline/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/sqlline/pom.xml b/contrib/sqlline/pom.xml
index d4963a6..6376e28 100644
--- a/contrib/sqlline/pom.xml
+++ b/contrib/sqlline/pom.xml
@@ -37,7 +37,6 @@
     <dependency>
       <groupId>sqlline</groupId>
       <artifactId>sqlline</artifactId>
-      <version>1.1.0</version>
     </dependency>
     <!-- Specify xalan and xerces versions to avoid setXIncludeAware error. -->
     <dependency>


Mime
View raw message