quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jianq...@apache.org
Subject [32/32] incubator-quickstep git commit: Refactor type system and operations.
Date Thu, 04 May 2017 03:23:16 GMT
Refactor type system and operations.


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

Branch: refs/heads/new-op
Commit: 583724ea83731fc1fe7a25a39da568b590f64432
Parents: 0572f40
Author: Jianqiao Zhu <jianqiao@cs.wisc.edu>
Authored: Sat Mar 4 12:11:13 2017 -0600
Committer: Jianqiao Zhu <jianqiao@cs.wisc.edu>
Committed: Wed May 3 22:22:35 2017 -0500

----------------------------------------------------------------------
 expressions/CMakeLists.txt                      |    4 +-
 expressions/ExpressionFactories.cpp             |   61 +-
 expressions/Expressions.proto                   |   12 +-
 .../aggregation/AggregateFunctionAvg.cpp        |   21 +-
 .../aggregation/AggregateFunctionSum.cpp        |    9 +-
 .../aggregation/AggregationHandleAvg.cpp        |   30 +-
 .../aggregation/AggregationHandleSum.cpp        |   15 +-
 expressions/aggregation/CMakeLists.txt          |   12 +-
 expressions/predicate/CMakeLists.txt            |    1 -
 expressions/scalar/CMakeLists.txt               |   16 +-
 expressions/scalar/ScalarBinaryExpression.cpp   |  101 +-
 expressions/scalar/ScalarBinaryExpression.hpp   |   31 +-
 expressions/scalar/ScalarUnaryExpression.cpp    |  100 +-
 expressions/scalar/ScalarUnaryExpression.hpp    |   27 +-
 expressions/window_aggregation/CMakeLists.txt   |    9 +-
 .../WindowAggregateFunctionAvg.cpp              |   17 +-
 .../WindowAggregateFunctionSum.cpp              |    8 +-
 .../WindowAggregationHandle.cpp                 |    8 +-
 .../WindowAggregationHandle.hpp                 |    2 -
 .../WindowAggregationHandleAvg.cpp              |   47 +-
 parser/CMakeLists.txt                           |    6 -
 parser/ParseBasicExpressions.cpp                |  103 -
 parser/ParseBasicExpressions.hpp                |  291 +-
 parser/ParseExpression.hpp                      |    3 -
 parser/SqlLexer.lpp                             |    1 +
 parser/SqlParser.ypp                            |   93 +-
 parser/preprocessed/SqlLexer_gen.cpp            | 1507 ++++----
 parser/preprocessed/SqlLexer_gen.hpp            |  192 +-
 parser/preprocessed/SqlParser_gen.cpp           | 3348 +++++++++---------
 parser/preprocessed/SqlParser_gen.hpp           |  203 +-
 query_optimizer/LogicalGenerator.cpp            |    7 +-
 .../expressions/BinaryExpression.cpp            |   85 +-
 .../expressions/BinaryExpression.hpp            |   70 +-
 query_optimizer/expressions/CMakeLists.txt      |   23 +-
 query_optimizer/expressions/Cast.cpp            |   91 -
 query_optimizer/expressions/Cast.hpp            |  125 -
 query_optimizer/expressions/UnaryExpression.cpp |   51 +-
 query_optimizer/expressions/UnaryExpression.hpp |   43 +-
 query_optimizer/resolver/CMakeLists.txt         |    6 +-
 query_optimizer/resolver/Resolver.cpp           |  415 +--
 query_optimizer/resolver/Resolver.hpp           |    9 +-
 query_optimizer/rules/CMakeLists.txt            |    4 +-
 .../rules/ReuseAggregateExpressions.cpp         |   19 +-
 query_optimizer/rules/tests/CMakeLists.txt      |    2 -
 query_optimizer/strategy/tests/CMakeLists.txt   |    2 -
 query_optimizer/tests/CMakeLists.txt            |    2 -
 query_optimizer/tests/OptimizerTest.cpp         |    2 -
 relational_operators/CMakeLists.txt             |    2 -
 storage/CMakeLists.txt                          |    5 +-
 storage/PackedPayloadHashTable.cpp              |    4 +-
 storage/SMAIndexSubBlock.cpp                    |   10 +-
 types/AsciiStringSuperType.hpp                  |   78 +
 types/BoolType.cpp                              |   63 +
 types/BoolType.hpp                              |   73 +
 types/CMakeLists.txt                            |   89 +-
 types/CharType.cpp                              |   32 -
 types/CharType.hpp                              |   77 +-
 types/DateType.cpp                              |   19 -
 types/DateType.hpp                              |   67 +-
 types/DatetimeIntervalType.cpp                  |   19 -
 types/DatetimeIntervalType.hpp                  |   67 +-
 types/DatetimeLit.hpp                           |    4 +
 types/DatetimeType.cpp                          |   19 -
 types/DatetimeType.hpp                          |   68 +-
 types/DoubleType.cpp                            |   36 -
 types/DoubleType.hpp                            |   59 +-
 types/FloatType.cpp                             |   36 -
 types/FloatType.hpp                             |   59 +-
 types/IntType.cpp                               |   35 -
 types/IntType.hpp                               |   59 +-
 types/LongType.cpp                              |   36 -
 types/LongType.hpp                              |   59 +-
 types/NullCoercibilityCheckMacro.hpp            |    5 +-
 types/NullType.hpp                              |   49 +-
 types/NumericSuperType.hpp                      |   69 +-
 types/NumericTypeSafeCoercibility.hpp           |   61 +
 types/NumericTypeUnifier.hpp                    |  102 +-
 types/Type.cpp                                  |   68 +-
 types/Type.hpp                                  |   60 +-
 types/Type.proto                                |   36 +-
 types/TypeFactory.cpp                           |  133 +-
 types/TypeFactory.hpp                           |   20 +-
 types/TypeID.cpp                                |    1 +
 types/TypeID.hpp                                |   36 +-
 types/TypeIDSelectors.hpp                       |  152 +
 types/TypeRegistrar.hpp                         |  122 +
 types/TypeSynthesizer.hpp                       |  210 ++
 types/TypeUtil.hpp                              |   70 +
 types/TypedValue.cpp                            |   47 +-
 types/TypedValue.hpp                            |   48 +-
 types/TypedValue.proto                          |   21 +-
 types/VarCharType.cpp                           |   32 -
 types/VarCharType.hpp                           |   73 +-
 types/YearMonthIntervalType.cpp                 |   19 -
 types/YearMonthIntervalType.hpp                 |   67 +-
 types/containers/ColumnVector.cpp               |    4 +
 types/containers/ColumnVector.hpp               |   22 +-
 types/operations/CMakeLists.txt                 |   43 +
 types/operations/Operation.hpp                  |   26 +-
 types/operations/Operation.proto                |   59 +-
 types/operations/OperationFactory.cpp           |  357 ++
 types/operations/OperationFactory.hpp           |  203 ++
 types/operations/OperationSignature.cpp         |   91 +
 types/operations/OperationSignature.hpp         |  182 +
 types/operations/OperationUtil.hpp              |  334 ++
 .../binary_operations/AddBinaryOperation.cpp    |  418 ---
 .../ArithmeticBinaryFunctorOverloads.hpp        |  176 +
 .../ArithmeticBinaryOperation.hpp               |  404 ---
 .../ArithmeticBinaryOperations.hpp              |  182 +
 .../ArithmeticBinaryOperators.hpp               |  848 -----
 .../AsciiStringBinaryOperations.hpp             |  130 +
 .../binary_operations/BinaryOperation.cpp       |   29 -
 .../binary_operations/BinaryOperation.hpp       |  300 +-
 .../BinaryOperationFactory.cpp                  |   93 -
 .../BinaryOperationFactory.hpp                  |   79 -
 .../binary_operations/BinaryOperationID.cpp     |   40 -
 .../binary_operations/BinaryOperationID.hpp     |   62 -
 .../BinaryOperationWrapper.hpp                  |  629 ++++
 .../operations/binary_operations/CMakeLists.txt |  187 +-
 .../binary_operations/CMathBinaryOperations.hpp |   78 +
 .../binary_operations/DivideBinaryOperation.cpp |  391 --
 .../binary_operations/DivideBinaryOperation.hpp |   93 -
 .../binary_operations/ModuloBinaryOperation.cpp |  259 --
 .../binary_operations/ModuloBinaryOperation.hpp |   93 -
 .../MultiplyBinaryOperation.cpp                 |  410 ---
 .../SubtractBinaryOperation.cpp                 |  459 ---
 .../SubtractBinaryOperation.hpp                 |   93 -
 types/operations/comparisons/CMakeLists.txt     |    6 +-
 types/operations/comparisons/Comparison.hpp     |    6 +-
 types/operations/comparisons/ComparisonUtil.hpp |   30 +-
 .../comparisons/PatternMatchingComparison.cpp   |   18 +-
 .../ArithmeticUnaryOperations.cpp               |  145 -
 .../ArithmeticUnaryOperations.hpp               |   93 +-
 .../ArithmeticUnaryOperators.hpp                |  169 -
 .../AsciiStringUnaryOperations.hpp              |  122 +
 .../operations/unary_operations/CMakeLists.txt  |  141 +-
 .../unary_operations/CMathUnaryOperations.hpp   |  116 +
 .../unary_operations/CastOperation.cpp          |  298 ++
 .../unary_operations/CastOperation.hpp          |  154 +
 .../unary_operations/DateExtractOperation.cpp   |  596 +---
 .../unary_operations/DateExtractOperation.hpp   |  193 +-
 .../unary_operations/NumericCastOperation.hpp   |  313 --
 .../unary_operations/SubstringOperation.cpp     |  198 +-
 .../unary_operations/SubstringOperation.hpp     |  286 +-
 .../unary_operations/UnaryOperation.cpp         |   20 -
 .../unary_operations/UnaryOperation.hpp         |  180 +-
 .../unary_operations/UnaryOperationFactory.cpp  |  120 -
 .../unary_operations/UnaryOperationFactory.hpp  |   79 -
 .../unary_operations/UnaryOperationID.cpp       |   32 -
 .../unary_operations/UnaryOperationID.hpp       |   63 -
 .../unary_operations/UnaryOperationWrapper.hpp  |  250 ++
 utility/CMakeLists.txt                          |   12 +-
 utility/StringUtil.cpp                          |    6 +
 utility/StringUtil.hpp                          |   12 +-
 utility/TemplateUtil.hpp                        |  198 --
 utility/meta/CMakeLists.txt                     |   41 +
 utility/meta/Common.hpp                         |  143 +
 utility/meta/Dispatchers.hpp                    |  107 +
 utility/meta/TMP.hpp                            |   28 +
 utility/meta/TransitiveClosure.hpp              |   97 +
 utility/meta/TypeList.hpp                       |  124 +
 utility/meta/TypeListMetaFunctions.hpp          |  245 ++
 utility/tests/TemplateUtil_unittest.cpp         |  115 -
 163 files changed, 9387 insertions(+), 11953 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/expressions/CMakeLists.txt b/expressions/CMakeLists.txt
index 33606cd..3d2e156 100644
--- a/expressions/CMakeLists.txt
+++ b/expressions/CMakeLists.txt
@@ -56,9 +56,9 @@ target_link_libraries(quickstep_expressions_ExpressionFactories
                       quickstep_expressions_scalar_ScalarUnaryExpression
                       quickstep_types_TypeFactory
                       quickstep_types_TypedValue
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
+                      quickstep_types_operations_OperationFactory
+                      quickstep_types_operations_OperationSignature
                       quickstep_types_operations_comparisons_ComparisonFactory
-                      quickstep_types_operations_unaryoperations_UnaryOperationFactory
                       quickstep_utility_Macros)
 target_link_libraries(quickstep_expressions_Expressions_proto
                       quickstep_types_Type_proto

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/ExpressionFactories.cpp
----------------------------------------------------------------------
diff --git a/expressions/ExpressionFactories.cpp b/expressions/ExpressionFactories.cpp
index 871db50..f8913ba 100644
--- a/expressions/ExpressionFactories.cpp
+++ b/expressions/ExpressionFactories.cpp
@@ -43,9 +43,9 @@
 #include "expressions/scalar/ScalarUnaryExpression.hpp"
 #include "types/TypeFactory.hpp"
 #include "types/TypedValue.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
+#include "types/operations/OperationFactory.hpp"
+#include "types/operations/OperationSignature.hpp"
 #include "types/operations/comparisons/ComparisonFactory.hpp"
-#include "types/operations/unary_operations/UnaryOperationFactory.hpp"
 #include "utility/Macros.hpp"
 
 #include "glog/logging.h"
@@ -168,17 +168,43 @@ Scalar* ScalarFactory::ReconstructFromProto(const serialization::Scalar &proto,
           proto.GetExtension(serialization::ScalarAttribute::attribute_id)));
     }
     case serialization::Scalar::UNARY_EXPRESSION: {
+      std::vector<TypedValue> static_arguments;
+      const int num_static_args =
+          proto.ExtensionSize(serialization::ScalarUnaryExpression::static_arguments);
+      for (int i = 0; i < num_static_args; ++i) {
+        static_arguments.emplace_back(
+            TypedValue::ReconstructFromProto(
+                proto.GetExtension(serialization::ScalarUnaryExpression::static_arguments, i)));
+      }
+      const OperationSignaturePtr op_signature =
+          OperationSignature::ReconstructFromProto(
+              proto.GetExtension(serialization::ScalarUnaryExpression::op_signature));
       return new ScalarUnaryExpression(
-          UnaryOperationFactory::ReconstructFromProto(
-              proto.GetExtension(serialization::ScalarUnaryExpression::operation)),
-          ReconstructFromProto(proto.GetExtension(serialization::ScalarUnaryExpression::operand), database));
+          op_signature,
+          OperationFactory::Instance().getUnaryOperation(op_signature),
+          ReconstructFromProto(proto.GetExtension(serialization::ScalarUnaryExpression::operand), database),
+          std::make_shared<std::vector<TypedValue>>(std::move(static_arguments)));
     }
     case serialization::Scalar::BINARY_EXPRESSION: {
+      std::vector<TypedValue> static_arguments;
+      const int num_static_args =
+          proto.ExtensionSize(serialization::ScalarBinaryExpression::static_arguments);
+      for (int i = 0; i < num_static_args; ++i) {
+        static_arguments.emplace_back(
+            TypedValue::ReconstructFromProto(
+                proto.GetExtension(serialization::ScalarBinaryExpression::static_arguments, i)));
+      }
+      const OperationSignaturePtr op_signature =
+          OperationSignature::ReconstructFromProto(
+              proto.GetExtension(serialization::ScalarBinaryExpression::op_signature));
       return new ScalarBinaryExpression(
-          BinaryOperationFactory::ReconstructFromProto(
-              proto.GetExtension(serialization::ScalarBinaryExpression::operation)),
-          ReconstructFromProto(proto.GetExtension(serialization::ScalarBinaryExpression::left_operand), database),
-          ReconstructFromProto(proto.GetExtension(serialization::ScalarBinaryExpression::right_operand), database));
+          op_signature,
+          OperationFactory::Instance().getBinaryOperation(op_signature),
+          ReconstructFromProto(
+              proto.GetExtension(serialization::ScalarBinaryExpression::left_operand), database),
+          ReconstructFromProto(
+              proto.GetExtension(serialization::ScalarBinaryExpression::right_operand), database),
+          std::make_shared<std::vector<TypedValue>>(std::move(static_arguments)));
     }
     case serialization::Scalar::CASE_EXPRESSION: {
       const Type &result_type = TypeFactory::ReconstructFromProto(
@@ -248,22 +274,13 @@ bool ScalarFactory::ProtoIsValid(const serialization::Scalar &proto,
       break;
     }
     case serialization::Scalar::UNARY_EXPRESSION: {
-      if (proto.HasExtension(serialization::ScalarUnaryExpression::operation)
-          && proto.HasExtension(serialization::ScalarUnaryExpression::operand)) {
-        return UnaryOperationFactory::ProtoIsValid(proto.GetExtension(serialization::ScalarUnaryExpression::operation))
-               && ProtoIsValid(proto.GetExtension(serialization::ScalarUnaryExpression::operand), database);
-      }
+      // TODO
+      return true;
       break;
     }
     case serialization::Scalar::BINARY_EXPRESSION: {
-      if (proto.HasExtension(serialization::ScalarBinaryExpression::operation)
-          && proto.HasExtension(serialization::ScalarBinaryExpression::left_operand)
-          && proto.HasExtension(serialization::ScalarBinaryExpression::right_operand)) {
-        return BinaryOperationFactory::ProtoIsValid(
-                   proto.GetExtension(serialization::ScalarBinaryExpression::operation))
-               && ProtoIsValid(proto.GetExtension(serialization::ScalarBinaryExpression::left_operand), database)
-               && ProtoIsValid(proto.GetExtension(serialization::ScalarBinaryExpression::right_operand), database);
-      }
+      // TODO
+      return true;
       break;
     }
     case serialization::Scalar::CASE_EXPRESSION: {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/Expressions.proto
----------------------------------------------------------------------
diff --git a/expressions/Expressions.proto b/expressions/Expressions.proto
index 8b4611e..3a9e673 100644
--- a/expressions/Expressions.proto
+++ b/expressions/Expressions.proto
@@ -103,16 +103,18 @@ message ScalarAttribute {
 
 message ScalarUnaryExpression {
   extend Scalar {
-    optional UnaryOperation operation = 96;
-    optional Scalar operand = 97;
+    optional OperationSignature op_signature = 97;
+    optional Scalar operand = 98;
+    repeated TypedValue static_arguments = 99;
   }
 }
 
 message ScalarBinaryExpression {
   extend Scalar {
-    optional BinaryOperation operation = 128;
-    optional Scalar left_operand = 129;
-    optional Scalar right_operand = 130;
+    optional OperationSignature op_signature = 129;
+    optional Scalar left_operand = 130;
+    optional Scalar right_operand = 131;
+    repeated TypedValue static_arguments = 132;
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/aggregation/AggregateFunctionAvg.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregateFunctionAvg.cpp b/expressions/aggregation/AggregateFunctionAvg.cpp
index 040d7d9..b2b99c7 100644
--- a/expressions/aggregation/AggregateFunctionAvg.cpp
+++ b/expressions/aggregation/AggregateFunctionAvg.cpp
@@ -25,9 +25,8 @@
 #include "types/Type.hpp"
 #include "types/TypeFactory.hpp"
 #include "types/TypeID.hpp"
+#include "types/operations/OperationFactory.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 
 #include "glog/logging.h"
 
@@ -41,10 +40,15 @@ bool AggregateFunctionAvg::canApplyToTypes(
   }
 
   // Argument must be addable and divisible.
-  return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-             .canApplyToTypes(*argument_types.front(), *argument_types.front())
-         && BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
-             .canApplyToTypes(*argument_types.front(), TypeFactory::GetType(kDouble));
+  const Type &type = *argument_types.front();
+  if (!OperationFactory::Instance()
+          .getBinaryOperation("+", {type.getTypeID(), type.getTypeID()})
+              ->canApplyTo(type, type)) {
+    return false;
+  }
+  return OperationFactory::Instance()
+      .getBinaryOperation("/", {type.getTypeID(), kDouble})
+          ->canApplyTo(type, TypeFactory::GetType(kDouble));
 }
 
 const Type* AggregateFunctionAvg::resultTypeForArgumentTypes(
@@ -67,8 +71,9 @@ const Type* AggregateFunctionAvg::resultTypeForArgumentTypes(
       break;
   }
 
-  return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
-             .resultTypeForArgumentTypes(*sum_type, TypeFactory::GetType(kDouble));
+  return OperationFactory::Instance()
+      .getBinaryOperation("/", {sum_type->getTypeID(), kDouble})
+          ->getResultType(*sum_type, TypeFactory::GetType(kDouble));
 }
 
 AggregationHandle* AggregateFunctionAvg::createHandle(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/aggregation/AggregateFunctionSum.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregateFunctionSum.cpp b/expressions/aggregation/AggregateFunctionSum.cpp
index b62660f..11b33c0 100644
--- a/expressions/aggregation/AggregateFunctionSum.cpp
+++ b/expressions/aggregation/AggregateFunctionSum.cpp
@@ -25,9 +25,8 @@
 #include "types/Type.hpp"
 #include "types/TypeFactory.hpp"
 #include "types/TypeID.hpp"
+#include "types/operations/OperationFactory.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 
 #include "glog/logging.h"
 
@@ -41,8 +40,10 @@ bool AggregateFunctionSum::canApplyToTypes(
   }
 
   // Argument must be addable.
-  return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-             .canApplyToTypes(*argument_types.front(), *argument_types.front());
+  const Type &type = *argument_types.front();
+  return OperationFactory::Instance()
+      .getBinaryOperation("+", {type.getTypeID(), type.getTypeID()})
+          ->canApplyTo(type, type);
 }
 
 const Type* AggregateFunctionSum::resultTypeForArgumentTypes(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/aggregation/AggregationHandleAvg.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationHandleAvg.cpp b/expressions/aggregation/AggregationHandleAvg.cpp
index 46bec1e..1324fd8 100644
--- a/expressions/aggregation/AggregationHandleAvg.cpp
+++ b/expressions/aggregation/AggregationHandleAvg.cpp
@@ -32,9 +32,8 @@
 #include "types/TypeFactory.hpp"
 #include "types/TypeID.hpp"
 #include "types/TypedValue.hpp"
+#include "types/operations/OperationFactory.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 
 #include "glog/logging.h"
 
@@ -68,25 +67,24 @@ AggregationHandleAvg::AggregationHandleAvg(const Type &type)
 
   // Make operators to do arithmetic:
   // Add operator for summing argument values.
-  fast_add_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-          .makeUncheckedBinaryOperatorForTypes(sum_type, argument_type_));
+  fast_add_operator_.reset(OperationFactory::Instance()
+      .getBinaryOperation("+", {type_precision_id, argument_type_.getTypeID()})
+          ->makeUncheckedBinaryOperator(sum_type, argument_type_));
   // Add operator for merging states.
-  merge_add_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-          .makeUncheckedBinaryOperatorForTypes(sum_type, sum_type));
+  merge_add_operator_.reset(OperationFactory::Instance()
+      .getBinaryOperation("+", {type_precision_id, type_precision_id})
+          ->makeUncheckedBinaryOperator(sum_type, sum_type));
   // Divide operator for dividing sum by count to get final average.
-  divide_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
-          .makeUncheckedBinaryOperatorForTypes(sum_type,
-                                               TypeFactory::GetType(kDouble)));
+  divide_operator_.reset(OperationFactory::Instance()
+      .getBinaryOperation("/", {type_precision_id, kDouble})
+          ->makeUncheckedBinaryOperator(sum_type, TypeFactory::GetType(kDouble)));
 
   // Result is nullable, because AVG() over 0 values (or all NULL values) is
   // NULL.
-  result_type_ =
-      &(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
-            .resultTypeForArgumentTypes(sum_type, TypeFactory::GetType(kDouble))
-            ->getNullableVersion());
+  result_type_ = &OperationFactory::Instance()
+      .getBinaryOperation("/", {type_precision_id, kDouble})
+          ->getResultType(sum_type, TypeFactory::GetType(kDouble))
+              ->getNullableVersion();
 }
 
 AggregationState* AggregationHandleAvg::accumulateValueAccessor(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/aggregation/AggregationHandleSum.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationHandleSum.cpp b/expressions/aggregation/AggregationHandleSum.cpp
index 9f5f220..c7ee776 100644
--- a/expressions/aggregation/AggregationHandleSum.cpp
+++ b/expressions/aggregation/AggregationHandleSum.cpp
@@ -32,9 +32,8 @@
 #include "types/TypeFactory.hpp"
 #include "types/TypeID.hpp"
 #include "types/TypedValue.hpp"
+#include "types/operations/OperationFactory.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 
 #include "glog/logging.h"
 
@@ -67,13 +66,13 @@ AggregationHandleSum::AggregationHandleSum(const Type &type)
 
   // Make operators to do arithmetic:
   // Add operator for summing argument values.
-  fast_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-          .makeUncheckedBinaryOperatorForTypes(sum_type, argument_type_));
+  fast_operator_.reset(OperationFactory::Instance()
+      .getBinaryOperation("+", {type_precision_id, argument_type_.getTypeID()})
+          ->makeUncheckedBinaryOperator(sum_type, argument_type_));
   // Add operator for merging states.
-  merge_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-          .makeUncheckedBinaryOperatorForTypes(sum_type, sum_type));
+  merge_operator_.reset(OperationFactory::Instance()
+      .getBinaryOperation("+", {type_precision_id, type_precision_id})
+          ->makeUncheckedBinaryOperator(sum_type, sum_type));
 
   // Result is nullable, because SUM() over 0 values (or all NULL values) is
   // NULL.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/aggregation/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/expressions/aggregation/CMakeLists.txt b/expressions/aggregation/CMakeLists.txt
index 4220a8d..29a58c6 100644
--- a/expressions/aggregation/CMakeLists.txt
+++ b/expressions/aggregation/CMakeLists.txt
@@ -84,9 +84,8 @@ target_link_libraries(quickstep_expressions_aggregation_AggregateFunctionAvg
                       quickstep_types_Type
                       quickstep_types_TypeFactory
                       quickstep_types_TypeID
+                      quickstep_types_operations_OperationFactory
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_utility_Macros)
 target_link_libraries(quickstep_expressions_aggregation_AggregateFunctionCount
                       glog
@@ -135,9 +134,8 @@ target_link_libraries(quickstep_expressions_aggregation_AggregateFunctionSum
                       quickstep_types_Type
                       quickstep_types_TypeFactory
                       quickstep_types_TypeID
+                      quickstep_types_operations_OperationFactory
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_utility_Macros)
 target_link_libraries(quickstep_expressions_aggregation_AggregationConcreteHandle
                       glog
@@ -170,9 +168,8 @@ target_link_libraries(quickstep_expressions_aggregation_AggregationHandleAvg
                       quickstep_types_TypeFactory
                       quickstep_types_TypeID
                       quickstep_types_TypedValue
+                      quickstep_types_operations_OperationFactory
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_utility_Macros)
 target_link_libraries(quickstep_expressions_aggregation_AggregationHandleCount
                       glog
@@ -228,9 +225,8 @@ target_link_libraries(quickstep_expressions_aggregation_AggregationHandleSum
                       quickstep_types_TypeFactory
                       quickstep_types_TypeID
                       quickstep_types_TypedValue
+                      quickstep_types_operations_OperationFactory
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_utility_Macros)
 
 # Submodule all-in-one library:

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/predicate/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/expressions/predicate/CMakeLists.txt b/expressions/predicate/CMakeLists.txt
index 04abfc7..def0bc5 100644
--- a/expressions/predicate/CMakeLists.txt
+++ b/expressions/predicate/CMakeLists.txt
@@ -150,7 +150,6 @@ target_link_libraries(Predicate_unittest
                       quickstep_types_TypeID
                       quickstep_types_TypedValue
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_types_operations_comparisons_Comparison
                       quickstep_types_operations_comparisons_ComparisonFactory
                       quickstep_types_operations_comparisons_ComparisonID

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/scalar/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/expressions/scalar/CMakeLists.txt b/expressions/scalar/CMakeLists.txt
index 6b52231..a59635b 100644
--- a/expressions/scalar/CMakeLists.txt
+++ b/expressions/scalar/CMakeLists.txt
@@ -68,9 +68,9 @@ target_link_libraries(quickstep_expressions_scalar_ScalarBinaryExpression
                       quickstep_types_TypeErrors
                       quickstep_types_TypedValue
                       quickstep_types_containers_ColumnVector
+                      quickstep_types_operations_OperationSignature
                       quickstep_types_operations_Operation_proto
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_utility_Macros)
 target_link_libraries(quickstep_expressions_scalar_ScalarCaseExpression
                       quickstep_catalog_CatalogTypedefs
@@ -118,9 +118,9 @@ target_link_libraries(quickstep_expressions_scalar_ScalarUnaryExpression
                       quickstep_types_TypeErrors
                       quickstep_types_TypedValue
                       quickstep_types_containers_ColumnVector
+                      quickstep_types_operations_OperationSignature
                       quickstep_types_operations_Operation_proto
                       quickstep_types_operations_unaryoperations_UnaryOperation
-                      quickstep_types_operations_unaryoperations_UnaryOperationID
                       quickstep_utility_Macros)
 
 # Submodule all-in-one library:
@@ -161,12 +161,8 @@ target_link_libraries(ScalarCaseExpression_unittest
                       quickstep_types_TypedValue
                       quickstep_types_containers_ColumnVector
                       quickstep_types_containers_ColumnVectorsValueAccessor
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_types_operations_comparisons_ComparisonFactory
-                      quickstep_types_operations_comparisons_ComparisonID
-                      quickstep_types_operations_unaryoperations_UnaryOperationFactory
-                      quickstep_types_operations_unaryoperations_UnaryOperationID)
+                      quickstep_types_operations_comparisons_ComparisonID)
 add_test(ScalarCaseExpression_unittest ScalarCaseExpression_unittest)
 
 add_executable(Scalar_unittest "${CMAKE_CURRENT_SOURCE_DIR}/tests/Scalar_unittest.cpp")
@@ -189,11 +185,7 @@ target_link_libraries(Scalar_unittest
                       quickstep_types_TypeID
                       quickstep_types_TypedValue
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
-                      quickstep_types_operations_unaryoperations_NumericCastOperation
+                      quickstep_types_operations_unaryoperations_CastOperation
                       quickstep_types_operations_unaryoperations_UnaryOperation
-                      quickstep_types_operations_unaryoperations_UnaryOperationFactory
-                      quickstep_types_operations_unaryoperations_UnaryOperationID
                       quickstep_utility_Macros)
 add_test(Scalar_unittest Scalar_unittest)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/scalar/ScalarBinaryExpression.cpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarBinaryExpression.cpp b/expressions/scalar/ScalarBinaryExpression.cpp
index b3568f8..2f0a0d4 100644
--- a/expressions/scalar/ScalarBinaryExpression.cpp
+++ b/expressions/scalar/ScalarBinaryExpression.cpp
@@ -34,43 +34,71 @@
 #include "types/containers/ColumnVector.hpp"
 #include "types/operations/Operation.pb.h"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 
 #include "glog/logging.h"
 
 namespace quickstep {
 
-ScalarBinaryExpression::ScalarBinaryExpression(const BinaryOperation &operation,
-                                               Scalar *left_operand,
-                                               Scalar *right_operand)
-    : Scalar(*operation.resultTypeForArgumentTypes(left_operand->getType(),
-                                                   right_operand->getType())),
+ScalarBinaryExpression::ScalarBinaryExpression(
+    const OperationSignaturePtr &op_signature,
+    const BinaryOperationPtr &operation,
+    Scalar *left_operand,
+    Scalar *right_operand,
+    const std::shared_ptr<const std::vector<TypedValue>> &static_arguments)
+    : Scalar(*operation->getResultType(left_operand->getType(),
+                                       right_operand->getType(),
+                                       *static_arguments)),
+      op_signature_(op_signature),
       operation_(operation),
       left_operand_(left_operand),
-      right_operand_(right_operand) {
-  initHelper(false);
+      right_operand_(right_operand),
+      static_arguments_(static_arguments) {
+  DCHECK(operation_->canApplyTo(left_operand_->getType(),
+                                right_operand_->getType(),
+                                *static_arguments));
+  fast_operator_.reset(
+      operation_->makeUncheckedBinaryOperator(left_operand_->getType(),
+                                              right_operand_->getType(),
+                                              *static_arguments));
+  if (left_operand_->hasStaticValue() && right_operand_->hasStaticValue()) {
+    static_value_.reset(new TypedValue(
+        fast_operator_->applyToTypedValues(left_operand_->getStaticValue(),
+                                           right_operand_->getStaticValue())));
+  }
 }
 
 serialization::Scalar ScalarBinaryExpression::getProto() const {
   serialization::Scalar proto;
   proto.set_data_source(serialization::Scalar::BINARY_EXPRESSION);
-  proto.MutableExtension(serialization::ScalarBinaryExpression::operation)->CopyFrom(operation_.getProto());
-  proto.MutableExtension(serialization::ScalarBinaryExpression::left_operand)->CopyFrom(left_operand_->getProto());
-  proto.MutableExtension(serialization::ScalarBinaryExpression::right_operand)->CopyFrom(right_operand_->getProto());
-
+  proto.MutableExtension(
+      serialization::ScalarBinaryExpression::op_signature)->CopyFrom(
+          op_signature_->getProto());
+  proto.MutableExtension(
+      serialization::ScalarBinaryExpression::left_operand)->CopyFrom(
+          left_operand_->getProto());
+  proto.MutableExtension(
+      serialization::ScalarBinaryExpression::right_operand)->CopyFrom(
+          right_operand_->getProto());
+  for (const TypedValue &value : *static_arguments_) {
+    proto.AddExtension(
+        serialization::ScalarUnaryExpression::static_arguments)->CopyFrom(
+            value.getProto());
+  }
   return proto;
 }
 
 Scalar* ScalarBinaryExpression::clone() const {
-  return new ScalarBinaryExpression(operation_,
+  return new ScalarBinaryExpression(op_signature_,
+                                    operation_,
                                     left_operand_->clone(),
-                                    right_operand_->clone());
+                                    right_operand_->clone(),
+                                    static_arguments_);
 }
 
 TypedValue ScalarBinaryExpression::getValueForSingleTuple(const ValueAccessor &accessor,
                                                           const tuple_id tuple) const {
   if (fast_operator_.get() == nullptr) {
-    return static_value_.makeReferenceToThis();
+    return static_value_->makeReferenceToThis();
   } else {
     return fast_operator_->applyToTypedValues(left_operand_->getValueForSingleTuple(accessor, tuple),
                                               right_operand_->getValueForSingleTuple(accessor, tuple));
@@ -85,7 +113,7 @@ TypedValue ScalarBinaryExpression::getValueForJoinedTuples(
     const relation_id right_relation_id,
     const tuple_id right_tuple_id) const {
   if (fast_operator_.get() == nullptr) {
-    return static_value_.makeReferenceToThis();
+    return static_value_->makeReferenceToThis();
   } else {
     return fast_operator_->applyToTypedValues(
         left_operand_->getValueForJoinedTuples(left_accessor,
@@ -110,7 +138,7 @@ ColumnVectorPtr ScalarBinaryExpression::getAllValues(
   if (fast_operator_.get() == nullptr) {
     return ColumnVectorPtr(
         ColumnVector::MakeVectorOfValue(getType(),
-                                        static_value_,
+                                        *static_value_,
                                         accessor->getNumTuplesVirtual()));
   } else {
     // NOTE(chasseur): We don't check if BOTH operands have a static value,
@@ -208,7 +236,7 @@ ColumnVectorPtr ScalarBinaryExpression::getAllValuesForJoin(
   if (fast_operator_.get() == nullptr) {
     return ColumnVectorPtr(
         ColumnVector::MakeVectorOfValue(getType(),
-                                        static_value_,
+                                        *static_value_,
                                         joined_tuple_ids.size()));
   } else {
     if (left_operand_->hasStaticValue()) {
@@ -380,31 +408,6 @@ ColumnVectorPtr ScalarBinaryExpression::getAllValuesForJoin(
   }
 }
 
-void ScalarBinaryExpression::initHelper(bool own_children) {
-  if (operation_.canApplyToTypes(left_operand_->getType(), right_operand_->getType())) {
-    if (left_operand_->hasStaticValue() && right_operand_->hasStaticValue()) {
-      static_value_ = operation_.applyToChecked(left_operand_->getStaticValue(),
-                                                left_operand_->getType(),
-                                                right_operand_->getStaticValue(),
-                                                right_operand_->getType());
-    } else {
-      fast_operator_.reset(operation_.makeUncheckedBinaryOperatorForTypes(left_operand_->getType(),
-                                                                           right_operand_->getType()));
-    }
-  } else {
-    const Type &left_operand_type = left_operand_->getType();
-    const Type &right_operand_type = right_operand_->getType();
-    if (!own_children) {
-      left_operand_.release();
-      right_operand_.release();
-    }
-    throw OperationInapplicableToType(operation_.getName(),
-                                      2,
-                                      left_operand_type.getName().c_str(),
-                                      right_operand_type.getName().c_str());
-  }
-}
-
 void ScalarBinaryExpression::getFieldStringItems(
     std::vector<std::string> *inline_field_names,
     std::vector<std::string> *inline_field_values,
@@ -419,19 +422,17 @@ void ScalarBinaryExpression::getFieldStringItems(
                               container_child_field_names,
                               container_child_fields);
 
-  if (fast_operator_ == nullptr) {
+  if (static_value_ != nullptr) {
     inline_field_names->emplace_back("static_value");
-    if (static_value_.isNull()) {
+    if (static_value_->isNull()) {
       inline_field_values->emplace_back("NULL");
     } else {
-      inline_field_values->emplace_back(type_.printValueToString(static_value_));
+      inline_field_values->emplace_back(type_.printValueToString(*static_value_));
     }
   }
 
-  inline_field_names->emplace_back("operation");
-  inline_field_values->emplace_back(
-      kBinaryOperationNames[static_cast<std::underlying_type<BinaryOperationID>::type>(
-          operation_.getBinaryOperationID())]);
+  inline_field_names->emplace_back("op_signature");
+  inline_field_values->emplace_back(op_signature_->toString());
 
   non_container_child_field_names->emplace_back("left_operand");
   non_container_child_fields->emplace_back(left_operand_.get());

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/scalar/ScalarBinaryExpression.hpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarBinaryExpression.hpp b/expressions/scalar/ScalarBinaryExpression.hpp
index 4ac1f62..a27c820 100644
--- a/expressions/scalar/ScalarBinaryExpression.hpp
+++ b/expressions/scalar/ScalarBinaryExpression.hpp
@@ -31,6 +31,7 @@
 #include "storage/StorageBlockInfo.hpp"
 #include "types/TypedValue.hpp"
 #include "types/containers/ColumnVector.hpp"
+#include "types/operations/OperationSignature.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
 #include "utility/Macros.hpp"
 
@@ -52,18 +53,11 @@ struct SubBlocksReference;
  **/
 class ScalarBinaryExpression : public Scalar {
  public:
-  /**
-   * @brief Constructor.
-   *
-   * @param operation The binary operation to be performed.
-   * @param left_operand The left argument of the operation, which this
-   *        ScalarBinaryExpression takes ownership of.
-   * @param right_operand The right argument of the operation, which this
-   *        ScalarBinaryExpression takes ownership of.
-   **/
-  ScalarBinaryExpression(const BinaryOperation &operation,
+  ScalarBinaryExpression(const OperationSignaturePtr &op_signature,
+                         const BinaryOperationPtr &operation,
                          Scalar *left_operand,
-                         Scalar *right_operand);
+                         Scalar *right_operand,
+                         const std::shared_ptr<const std::vector<TypedValue>> &static_arguments);
 
   /**
    * @brief Destructor
@@ -91,12 +85,12 @@ class ScalarBinaryExpression : public Scalar {
       const tuple_id right_tuple_id) const override;
 
   bool hasStaticValue() const override {
-    return fast_operator_.get() == nullptr;
+    return static_value_ != nullptr;
   }
 
   const TypedValue& getStaticValue() const override {
     DCHECK(hasStaticValue());
-    return static_value_;
+    return *static_value_;
   }
 
   ColumnVectorPtr getAllValues(ValueAccessor *accessor,
@@ -121,13 +115,14 @@ class ScalarBinaryExpression : public Scalar {
       std::vector<std::vector<const Expression*>> *container_child_fields) const override;
 
  private:
-  void initHelper(bool own_children);
+  const OperationSignaturePtr op_signature_;
+  const BinaryOperationPtr operation_;
 
-  const BinaryOperation &operation_;
+  const std::unique_ptr<Scalar> left_operand_;
+  const std::unique_ptr<Scalar> right_operand_;
+  const std::shared_ptr<const std::vector<TypedValue>> static_arguments_;
 
-  std::unique_ptr<Scalar> left_operand_;
-  std::unique_ptr<Scalar> right_operand_;
-  TypedValue static_value_;
+  std::unique_ptr<TypedValue> static_value_;
   std::unique_ptr<UncheckedBinaryOperator> fast_operator_;
 
   friend class PredicateTest;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/scalar/ScalarUnaryExpression.cpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarUnaryExpression.cpp b/expressions/scalar/ScalarUnaryExpression.cpp
index c51e38f..c2fd931 100644
--- a/expressions/scalar/ScalarUnaryExpression.cpp
+++ b/expressions/scalar/ScalarUnaryExpression.cpp
@@ -34,41 +34,62 @@
 #include "types/containers/ColumnVector.hpp"
 #include "types/operations/Operation.pb.h"
 #include "types/operations/unary_operations/UnaryOperation.hpp"
-#include "types/operations/unary_operations/UnaryOperationID.hpp"
 
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_JOIN
 #include "glog/logging.h"
-#endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_JOIN
 
 namespace quickstep {
 
 struct SubBlocksReference;
 
-ScalarUnaryExpression::ScalarUnaryExpression(const UnaryOperation &operation,
-                                             Scalar *operand)
-    : Scalar(*operation.resultTypeForArgumentType(operand->getType())),
+ScalarUnaryExpression::ScalarUnaryExpression(
+    const OperationSignaturePtr &op_signature,
+    const UnaryOperationPtr &operation,
+    Scalar *operand,
+    const std::shared_ptr<const std::vector<TypedValue>> &static_arguments)
+    : Scalar(*operation->getResultType(operand->getType(), *static_arguments)),
+      op_signature_(op_signature),
       operation_(operation),
-      operand_(operand) {
-  initHelper(false);
+      operand_(operand),
+      static_arguments_(static_arguments) {
+  DCHECK(operation_->canApplyTo(operand_->getType(), *static_arguments_));
+
+  fast_operator_.reset(
+      operation_->makeUncheckedUnaryOperator(operand_->getType(),
+                                             *static_arguments_));
+  if (operand_->hasStaticValue()) {
+    static_value_.reset(new TypedValue(
+        fast_operator_->applyToTypedValue(operand_->getStaticValue())));
+  }
 }
 
 serialization::Scalar ScalarUnaryExpression::getProto() const {
   serialization::Scalar proto;
   proto.set_data_source(serialization::Scalar::UNARY_EXPRESSION);
-  proto.MutableExtension(serialization::ScalarUnaryExpression::operation)->CopyFrom(operation_.getProto());
-  proto.MutableExtension(serialization::ScalarUnaryExpression::operand)->CopyFrom(operand_->getProto());
-
+  proto.MutableExtension(
+      serialization::ScalarUnaryExpression::op_signature)->CopyFrom(
+          op_signature_->getProto());
+  proto.MutableExtension(
+      serialization::ScalarUnaryExpression::operand)->CopyFrom(
+          operand_->getProto());
+  for (const TypedValue &value : *static_arguments_) {
+    proto.AddExtension(
+        serialization::ScalarUnaryExpression::static_arguments)->CopyFrom(
+            value.getProto());
+  }
   return proto;
 }
 
 Scalar* ScalarUnaryExpression::clone() const {
-  return new ScalarUnaryExpression(operation_, operand_->clone());
+  return new ScalarUnaryExpression(op_signature_,
+                                   operation_,
+                                   operand_->clone(),
+                                   static_arguments_);
 }
 
 TypedValue ScalarUnaryExpression::getValueForSingleTuple(const ValueAccessor &accessor,
                                                          const tuple_id tuple) const {
   if (fast_operator_.get() == nullptr) {
-    return static_value_.makeReferenceToThis();
+    return static_value_->makeReferenceToThis();
   } else {
     return fast_operator_->applyToTypedValue(operand_->getValueForSingleTuple(accessor, tuple));
   }
@@ -82,7 +103,7 @@ TypedValue ScalarUnaryExpression::getValueForJoinedTuples(
     const relation_id right_relation_id,
     const tuple_id right_tuple_id) const {
   if (fast_operator_.get() == nullptr) {
-    return static_value_.makeReferenceToThis();
+    return static_value_->makeReferenceToThis();
   } else {
     return fast_operator_->applyToTypedValue(operand_->getValueForJoinedTuples(left_accessor,
                                                                                left_relation_id,
@@ -100,7 +121,7 @@ ColumnVectorPtr ScalarUnaryExpression::getAllValues(
   if (fast_operator_.get() == nullptr) {
     return ColumnVectorPtr(
         ColumnVector::MakeVectorOfValue(getType(),
-                                        static_value_,
+                                        *static_value_,
                                         accessor->getNumTuplesVirtual()));
   } else {
 #ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
@@ -128,27 +149,9 @@ ColumnVectorPtr ScalarUnaryExpression::getAllValuesForJoin(
   if (fast_operator_.get() == nullptr) {
     return ColumnVectorPtr(
         ColumnVector::MakeVectorOfValue(getType(),
-                                        static_value_,
+                                        *static_value_,
                                         joined_tuple_ids.size()));
   } else {
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_JOIN
-    const attribute_id operand_attr_id = operand_->getAttributeIdForValueAccessor();
-    if (operand_attr_id != -1) {
-      const relation_id operand_relation_id = operand_->getRelationIdForValueAccessor();
-      DCHECK_NE(operand_relation_id, -1);
-      DCHECK((operand_relation_id == left_relation_id)
-             || (operand_relation_id == right_relation_id));
-      const bool using_left_relation = (operand_relation_id == left_relation_id);
-      ValueAccessor *operand_accessor = using_left_relation ? left_accessor
-                                                            : right_accessor;
-      return ColumnVectorPtr(
-          fast_operator_->applyToValueAccessorForJoin(operand_accessor,
-                                                      using_left_relation,
-                                                      operand_attr_id,
-                                                      joined_tuple_ids));
-    }
-#endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_JOIN
-
     ColumnVectorPtr operand_result(
         operand_->getAllValuesForJoin(left_relation_id,
                                       left_accessor,
@@ -161,23 +164,6 @@ ColumnVectorPtr ScalarUnaryExpression::getAllValuesForJoin(
   }
 }
 
-void ScalarUnaryExpression::initHelper(bool own_children) {
-  if (operation_.canApplyToType(operand_->getType())) {
-    if (operand_->hasStaticValue()) {
-      static_value_ = operation_.applyToChecked(operand_->getStaticValue(),
-                                                operand_->getType());
-    } else {
-      fast_operator_.reset(operation_.makeUncheckedUnaryOperatorForType(operand_->getType()));
-    }
-  } else {
-    const Type &operand_type = operand_->getType();
-    if (!own_children) {
-      operand_.release();
-    }
-    throw OperationInapplicableToType(operation_.getName(), 1, operand_type.getName().c_str());
-  }
-}
-
 void ScalarUnaryExpression::getFieldStringItems(
     std::vector<std::string> *inline_field_names,
     std::vector<std::string> *inline_field_values,
@@ -192,19 +178,17 @@ void ScalarUnaryExpression::getFieldStringItems(
                               container_child_field_names,
                               container_child_fields);
 
-  if (fast_operator_ == nullptr) {
+  if (static_value_ != nullptr) {
     inline_field_names->emplace_back("static_value");
-    if (static_value_.isNull()) {
+    if (static_value_->isNull()) {
       inline_field_values->emplace_back("NULL");
     } else {
-      inline_field_values->emplace_back(type_.printValueToString(static_value_));
+      inline_field_values->emplace_back(type_.printValueToString(*static_value_));
     }
   }
 
-  inline_field_names->emplace_back("operation");
-  inline_field_values->emplace_back(
-      kUnaryOperationNames[static_cast<std::underlying_type<UnaryOperationID>::type>(
-          operation_.getUnaryOperationID())]);
+  inline_field_names->emplace_back("op_signature");
+  inline_field_values->emplace_back(op_signature_->toString());
 
   non_container_child_field_names->emplace_back("operand");
   non_container_child_fields->emplace_back(operand_.get());

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/scalar/ScalarUnaryExpression.hpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarUnaryExpression.hpp b/expressions/scalar/ScalarUnaryExpression.hpp
index 52edea7..8dc4c30 100644
--- a/expressions/scalar/ScalarUnaryExpression.hpp
+++ b/expressions/scalar/ScalarUnaryExpression.hpp
@@ -30,6 +30,8 @@
 #include "expressions/scalar/Scalar.hpp"
 #include "storage/StorageBlockInfo.hpp"
 #include "types/TypedValue.hpp"
+#include "types/containers/ColumnVector.hpp"
+#include "types/operations/OperationSignature.hpp"
 #include "types/operations/unary_operations/UnaryOperation.hpp"
 #include "utility/Macros.hpp"
 
@@ -51,14 +53,10 @@ struct SubBlocksReference;
  **/
 class ScalarUnaryExpression : public Scalar {
  public:
-  /**
-   * @brief Constructor.
-   *
-   * @param operation The unary operation to be performed.
-   * @param operand The argument of the operation, which this
-   *        ScalarUnaryExpression takes ownership of.
-   **/
-  ScalarUnaryExpression(const UnaryOperation &operation, Scalar *operand);
+  ScalarUnaryExpression(const OperationSignaturePtr &op_signature,
+                        const UnaryOperationPtr &operation,
+                        Scalar *operand,
+                        const std::shared_ptr<const std::vector<TypedValue>> &static_arguments);
 
   /**
    * @brief Destructor.
@@ -86,12 +84,12 @@ class ScalarUnaryExpression : public Scalar {
       const tuple_id right_tuple_id) const override;
 
   bool hasStaticValue() const override {
-    return fast_operator_.get() == nullptr;
+    return static_value_ != nullptr;
   }
 
   const TypedValue& getStaticValue() const override {
     DCHECK(hasStaticValue());
-    return static_value_;
+    return *static_value_;
   }
 
   ColumnVectorPtr getAllValues(ValueAccessor *accessor,
@@ -116,12 +114,13 @@ class ScalarUnaryExpression : public Scalar {
       std::vector<std::vector<const Expression*>> *container_child_fields) const override;
 
  private:
-  void initHelper(bool own_children);
+  const OperationSignaturePtr op_signature_;
+  const UnaryOperationPtr operation_;
 
-  const UnaryOperation &operation_;
+  const std::unique_ptr<Scalar> operand_;
+  const std::shared_ptr<const std::vector<TypedValue>> static_arguments_;
 
-  std::unique_ptr<Scalar> operand_;
-  TypedValue static_value_;
+  std::unique_ptr<TypedValue> static_value_;
   std::unique_ptr<UncheckedUnaryOperator> fast_operator_;
 
   friend class PredicateTest;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/window_aggregation/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/CMakeLists.txt b/expressions/window_aggregation/CMakeLists.txt
index b33a401..1b5b743 100644
--- a/expressions/window_aggregation/CMakeLists.txt
+++ b/expressions/window_aggregation/CMakeLists.txt
@@ -72,8 +72,6 @@ target_link_libraries(quickstep_expressions_windowaggregation_WindowAggregateFun
                       quickstep_types_TypeFactory
                       quickstep_types_TypeID
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_utility_Macros)
 target_link_libraries(quickstep_expressions_windowaggregation_WindowAggregateFunctionCount
                       glog
@@ -123,8 +121,6 @@ target_link_libraries(quickstep_expressions_windowaggregation_WindowAggregateFun
                       quickstep_types_TypeFactory
                       quickstep_types_TypeID
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_utility_Macros)
 target_link_libraries(quickstep_expressions_windowaggregation_WindowAggregationHandle
                       glog
@@ -138,9 +134,8 @@ target_link_libraries(quickstep_expressions_windowaggregation_WindowAggregationH
                       quickstep_types_TypedValue
                       quickstep_types_containers_ColumnVector
                       quickstep_types_containers_ColumnVectorsValueAccessor
+                      quickstep_types_operations_OperationFactory
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_types_operations_comparisons_Comparison
                       quickstep_types_operations_comparisons_ComparisonFactory
                       quickstep_types_operations_comparisons_ComparisonID
@@ -156,8 +151,6 @@ target_link_libraries(quickstep_expressions_windowaggregation_WindowAggregationH
                       quickstep_types_TypedValue
                       quickstep_types_containers_ColumnVectorsValueAccessor
                       quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_types_operations_comparisons_Comparison
                       quickstep_utility_Macros)
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp b/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
index 20c296b..a70a8bc 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
@@ -26,8 +26,6 @@
 #include "types/TypeFactory.hpp"
 #include "types/TypeID.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 
 #include "glog/logging.h"
 
@@ -41,10 +39,11 @@ bool WindowAggregateFunctionAvg::canApplyToTypes(
   }
 
   // Argument must be addable and divisible.
-  return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-             .canApplyToTypes(*argument_types.front(), *argument_types.front()) &&
-         BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
-             .canApplyToTypes(*argument_types.front(), TypeFactory::GetType(kDouble));
+//  return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
+//             .canApplyTo(*argument_types.front(), *argument_types.front()) &&
+//         BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
+//             .canApplyTo(*argument_types.front(), TypeFactory::GetType(kDouble));
+  return false;
 }
 
 const Type* WindowAggregateFunctionAvg::resultTypeForArgumentTypes(
@@ -67,8 +66,10 @@ const Type* WindowAggregateFunctionAvg::resultTypeForArgumentTypes(
       break;
   }
 
-  return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
-             .resultTypeForArgumentTypes(*sum_type, TypeFactory::GetType(kDouble));
+// TODO
+//  return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
+//             .getResultType(*sum_type, TypeFactory::GetType(kDouble));
+  return nullptr;
 }
 
 WindowAggregationHandle* WindowAggregateFunctionAvg::createHandle(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionSum.cpp b/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
index 14c51d8..e383c63 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
@@ -26,8 +26,6 @@
 #include "types/TypeFactory.hpp"
 #include "types/TypeID.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 
 #include "glog/logging.h"
 
@@ -41,8 +39,10 @@ bool WindowAggregateFunctionSum::canApplyToTypes(
   }
 
   // Argument must be addable.
-  return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-             .canApplyToTypes(*argument_types.front(), *argument_types.front());
+// TODO
+//  return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
+//             .canApplyTo(*argument_types.front(), *argument_types.front());
+  return false;
 }
 
 const Type* WindowAggregateFunctionSum::resultTypeForArgumentTypes(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/window_aggregation/WindowAggregationHandle.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandle.cpp b/expressions/window_aggregation/WindowAggregationHandle.cpp
index f26656d..7621726 100644
--- a/expressions/window_aggregation/WindowAggregationHandle.cpp
+++ b/expressions/window_aggregation/WindowAggregationHandle.cpp
@@ -30,9 +30,8 @@
 #include "types/TypeID.hpp"
 #include "types/TypedValue.hpp"
 #include "types/containers/ColumnVectorsValueAccessor.hpp"
+#include "types/operations/OperationFactory.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 #include "types/operations/comparisons/Comparison.hpp"
 
 #include "glog/logging.h"
@@ -83,8 +82,9 @@ WindowAggregationHandle::WindowAggregationHandle(
         TypeFactory::GetUnifyingType(*first_order_key_type, long_type);
 
     range_add_operator_.reset(
-        BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-            .makeUncheckedBinaryOperatorForTypes(*first_order_key_type, long_type));
+        OperationFactory::Instance().getBinaryOperation(
+            "+", {first_order_key_type->getTypeID(), kLong}, 0)
+                ->makeUncheckedBinaryOperator(*first_order_key_type, long_type));
     range_comparator_.reset(
         ComparisonFactory::GetComparison(ComparisonID::kLessOrEqual)
             .makeUncheckedComparatorForTypes(*range_compare_type_, *range_compare_type_));

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/window_aggregation/WindowAggregationHandle.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandle.hpp b/expressions/window_aggregation/WindowAggregationHandle.hpp
index 3569123..0d5f5ca 100644
--- a/expressions/window_aggregation/WindowAggregationHandle.hpp
+++ b/expressions/window_aggregation/WindowAggregationHandle.hpp
@@ -37,8 +37,6 @@
 #include "types/operations/comparisons/ComparisonFactory.hpp"
 #include "types/operations/comparisons/ComparisonID.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 #include "utility/Macros.hpp"
 
 namespace quickstep {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandleAvg.cpp b/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
index b1c6e3b..3539d03 100644
--- a/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
+++ b/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
@@ -32,8 +32,6 @@
 #include "types/TypedValue.hpp"
 #include "types/containers/ColumnVectorsValueAccessor.hpp"
 #include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
 #include "types/operations/comparisons/Comparison.hpp"
 
 #include "glog/logging.h"
@@ -71,28 +69,29 @@ WindowAggregationHandleAvg::WindowAggregationHandleAvg(
 
   sum_type_ = &(TypeFactory::GetType(type_id));
 
-  // Result is nullable, because AVG() over 0 values (or all NULL values) is
-  // NULL.
-  result_type_
-      = &(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
-              .resultTypeForArgumentTypes(*sum_type_, TypeFactory::GetType(kDouble))
-                  ->getNullableVersion());
-
-  // Make operators to do arithmetic:
-  // Add operator for summing argument values.
-  fast_add_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-          .makeUncheckedBinaryOperatorForTypes(*sum_type_, *argument_type));
-
-  // Subtract operator for dropping argument values off the window.
-  fast_subtract_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kSubtract)
-          .makeUncheckedBinaryOperatorForTypes(*sum_type_, *argument_type));
-
-  // Divide operator for dividing sum by count to get final average.
-  divide_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
-          .makeUncheckedBinaryOperatorForTypes(*sum_type_, TypeFactory::GetType(kDouble)));
+// TODO
+//  // Result is nullable, because AVG() over 0 values (or all NULL values) is
+//  // NULL.
+//  result_type_
+//      = &(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
+//              .getResultType(*sum_type_, TypeFactory::GetType(kDouble))
+//                  ->getNullableVersion());
+//
+//  // Make operators to do arithmetic:
+//  // Add operator for summing argument values.
+//  fast_add_operator_.reset(
+//      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
+//          .makeUncheckedBinaryOperator(*sum_type_, *argument_type));
+//
+//  // Subtract operator for dropping argument values off the window.
+//  fast_subtract_operator_.reset(
+//      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kSubtract)
+//          .makeUncheckedBinaryOperator(*sum_type_, *argument_type));
+//
+//  // Divide operator for dividing sum by count to get final average.
+//  divide_operator_.reset(
+//      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
+//          .makeUncheckedBinaryOperator(*sum_type_, TypeFactory::GetType(kDouble)));
 }
 
 ColumnVector* WindowAggregationHandleAvg::calculate(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/parser/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt
index b3ddf30..fb7a3cd 100644
--- a/parser/CMakeLists.txt
+++ b/parser/CMakeLists.txt
@@ -366,15 +366,9 @@ target_link_libraries(quickstep_parser_SqlParser
                       quickstep_types_Type
                       quickstep_types_TypeFactory
                       quickstep_types_TypeID
-                      quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
                       quickstep_types_operations_comparisons_Comparison
                       quickstep_types_operations_comparisons_ComparisonFactory
                       quickstep_types_operations_comparisons_ComparisonID
-                      quickstep_types_operations_unaryoperations_UnaryOperation
-                      quickstep_types_operations_unaryoperations_UnaryOperationFactory
-                      quickstep_types_operations_unaryoperations_UnaryOperationID
                       quickstep_utility_PtrList
                       quickstep_utility_PtrVector)
 target_link_libraries(quickstep_parser_SqlParserWrapper

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/parser/ParseBasicExpressions.cpp
----------------------------------------------------------------------
diff --git a/parser/ParseBasicExpressions.cpp b/parser/ParseBasicExpressions.cpp
index b0b1247..580cd09 100644
--- a/parser/ParseBasicExpressions.cpp
+++ b/parser/ParseBasicExpressions.cpp
@@ -68,54 +68,6 @@ void ParseAttribute::getFieldStringItems(
   }
 }
 
-std::string ParseUnaryExpression::getName() const {
-  return op_.getName();
-}
-
-string ParseUnaryExpression::generateName() const {
-  string name(op_.getShortName());
-  name.append(operand_->generateName());
-  return name;
-}
-
-void ParseUnaryExpression::getFieldStringItems(
-    std::vector<std::string> *inline_field_names,
-    std::vector<std::string> *inline_field_values,
-    std::vector<std::string> *non_container_child_field_names,
-    std::vector<const ParseTreeNode*> *non_container_child_fields,
-    std::vector<std::string> *container_child_field_names,
-    std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const {
-  non_container_child_field_names->push_back("");
-  non_container_child_fields->push_back(operand_.get());
-}
-
-std::string ParseBinaryExpression::getName() const {
-  return op_.getName();
-}
-
-string ParseBinaryExpression::generateName() const {
-  string name("(");
-  name.append(left_operand_->generateName());
-  name.append(op_.getShortName());
-  name.append(right_operand_->generateName());
-  name.push_back(')');
-  return name;
-}
-
-void ParseBinaryExpression::getFieldStringItems(
-    std::vector<std::string> *inline_field_names,
-    std::vector<std::string> *inline_field_values,
-    std::vector<std::string> *non_container_child_field_names,
-    std::vector<const ParseTreeNode*> *non_container_child_fields,
-    std::vector<std::string> *container_child_field_names,
-    std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const  {
-  non_container_child_field_names->push_back("left_operand");
-  non_container_child_fields->push_back(left_operand_.get());
-
-  non_container_child_field_names->push_back("right_operand");
-  non_container_child_fields->push_back(right_operand_.get());
-}
-
 std::string ParseFunctionCall::generateName() const {
   string name(name_->value());
   name.push_back('(');
@@ -175,59 +127,4 @@ void ParseFunctionCall::getFieldStringItems(
   }
 }
 
-std::string ParseExtractFunction::generateName() const {
-  std::string name;
-  name.append("EXTRACT(");
-  name.append(extract_field_->value());
-  name.append(" FROM ");
-  name.append(date_expression_->generateName());
-  name.push_back(')');
-  return name;
-}
-
-void ParseExtractFunction::getFieldStringItems(
-    std::vector<std::string> *inline_field_names,
-    std::vector<std::string> *inline_field_values,
-    std::vector<std::string> *non_container_child_field_names,
-    std::vector<const ParseTreeNode*> *non_container_child_fields,
-    std::vector<std::string> *container_child_field_names,
-    std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const {
-  inline_field_names->push_back("unit");
-  inline_field_values->push_back(extract_field_->value());
-
-  non_container_child_field_names->push_back("date_expression");
-  non_container_child_fields->push_back(date_expression_.get());
-}
-
-std::string ParseSubstringFunction::generateName() const {
-  std::string name;
-  name.append("SUBSTRING(");
-  name.append(operand_->generateName());
-  name.append(" FROM ");
-  name.append(std::to_string(start_position_));
-  if (length_ != kDefaultLength) {
-    name.append(" FOR ");
-    name.append(std::to_string(length_));
-  }
-  name.push_back(')');
-  return name;
-}
-
-void ParseSubstringFunction::getFieldStringItems(
-    std::vector<std::string> *inline_field_names,
-    std::vector<std::string> *inline_field_values,
-    std::vector<std::string> *non_container_child_field_names,
-    std::vector<const ParseTreeNode*> *non_container_child_fields,
-    std::vector<std::string> *container_child_field_names,
-    std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const {
-  inline_field_names->push_back("start_position");
-  inline_field_values->push_back(std::to_string(start_position_));
-
-  inline_field_names->push_back("length");
-  inline_field_values->push_back(std::to_string(length_));
-
-  non_container_child_field_names->push_back("operand");
-  non_container_child_fields->push_back(operand_.get());
-}
-
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/parser/ParseBasicExpressions.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseBasicExpressions.hpp b/parser/ParseBasicExpressions.hpp
index d8de669..4572214 100644
--- a/parser/ParseBasicExpressions.hpp
+++ b/parser/ParseBasicExpressions.hpp
@@ -36,9 +36,6 @@
 
 namespace quickstep {
 
-class BinaryOperation;
-class UnaryOperation;
-
 /** \addtogroup Parser
  *  @{
  */
@@ -173,155 +170,6 @@ class ParseAttribute : public ParseExpression {
 
 
 /**
- * @brief The parsed representation of an unary operation applied to an expression.
- **/
-class ParseUnaryExpression : public ParseExpression {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param line_number Line number of the first token of this node in the SQL statement.
-   * @param column_number Column number of the first token of this node in the SQL statement.
-   * @param op The UnaryOperation from the quickstep type system to apply.
-   * @param operand The parsed scalar representation of the unary operation's
-   *        argument, which becomes owned by this ParseScalarUnaryExpression.
-   **/
-  ParseUnaryExpression(const int line_number,
-                       const int column_number,
-                       const UnaryOperation &op,
-                       ParseExpression *operand)
-      : ParseExpression(line_number, column_number),
-        op_(op),
-        operand_(operand) {
-  }
-
-  /**
-   * @brief Destructor.
-   */
-  ~ParseUnaryExpression() override {
-  }
-
-  ExpressionType getExpressionType() const override {
-    return kUnaryExpression;
-  }
-
-  std::string getName() const override;
-
-  /**
-   * @return The unary operation.
-   */
-  const UnaryOperation& op() const {
-    return op_;
-  }
-
-  /**
-   * @return The operand expression.
-   */
-  const ParseExpression* operand() const {
-    return operand_.get();
-  }
-
-  std::string generateName() const override;
-
- protected:
-  void getFieldStringItems(
-      std::vector<std::string> *inline_field_names,
-      std::vector<std::string> *inline_field_values,
-      std::vector<std::string> *non_container_child_field_names,
-      std::vector<const ParseTreeNode*> *non_container_child_fields,
-      std::vector<std::string> *container_child_field_names,
-      std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const override;
-
- private:
-  const UnaryOperation &op_;
-  std::unique_ptr<ParseExpression> operand_;
-
-  DISALLOW_COPY_AND_ASSIGN(ParseUnaryExpression);
-};
-
-/**
- * @brief The parsed representation of a binary operation applied to two
- *        expressions.
- **/
-class ParseBinaryExpression : public ParseExpression {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param line_number Line number of the binary operator token in the SQL statement.
-   * @param column_number Column number of the binary operator token in the SQL statement.
-   * @param op The BinaryOperation from the quickstep type system to apply.
-   * @param left_operand The parsed scalar representation of the binary
-   *        operation's left argument, which becomes owned by this
-   *        ParseScalarBinaryExpression.
-   * @param right_operand The parsed scalar representation of the binary
-   *        operation's right argument, which becomes owned by this
-   *        ParseScalarBinaryExpression.
-   **/
-  ParseBinaryExpression(const int line_number,
-                        const int column_number,
-                        const BinaryOperation &op,
-                        ParseExpression *left_operand,
-                        ParseExpression *right_operand)
-      : ParseExpression(line_number, column_number),
-        op_(op),
-        left_operand_(left_operand),
-        right_operand_(right_operand) {
-  }
-
-  /**
-   * @brief Destructor.
-   */
-  ~ParseBinaryExpression() override {
-  }
-
-  ExpressionType getExpressionType() const override {
-    return kBinaryExpression;
-  }
-
-  std::string getName() const override;
-
-  /**
-   * @return The binary operation.
-   */
-  const BinaryOperation& op() const {
-    return op_;
-  }
-
-  /**
-   * @return The left operand expression.
-   */
-  const ParseExpression* left_operand() const {
-    return left_operand_.get();
-  }
-
-  /**
-   * @return The right operand expression.
-   */
-  const ParseExpression* right_operand() const {
-    return right_operand_.get();
-  }
-
-  std::string generateName() const override;
-
- protected:
-  void getFieldStringItems(
-      std::vector<std::string> *inline_field_names,
-      std::vector<std::string> *inline_field_values,
-      std::vector<std::string> *non_container_child_field_names,
-      std::vector<const ParseTreeNode*> *non_container_child_fields,
-      std::vector<std::string> *container_child_field_names,
-      std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const override;
-
- private:
-  const BinaryOperation &op_;
-  std::unique_ptr<ParseExpression> left_operand_;
-  std::unique_ptr<ParseExpression> right_operand_;
-
-  DISALLOW_COPY_AND_ASSIGN(ParseBinaryExpression);
-};
-
-/**
  * @brief The parsed representation of '*' as a function argument.
  */
 class ParseStar : public ParseTreeNode {
@@ -346,6 +194,7 @@ class ParseStar : public ParseTreeNode {
   DISALLOW_COPY_AND_ASSIGN(ParseStar);
 };
 
+
 /**
  * @brief Parsed function call in the form of a name with a list of arguments in parentheses.
  */
@@ -495,144 +344,6 @@ class ParseFunctionCall : public ParseExpression {
   DISALLOW_COPY_AND_ASSIGN(ParseFunctionCall);
 };
 
-
-/**
- * @brief Parsed representation of EXTRACT(unit FROM date).
- */
-class ParseExtractFunction : public ParseExpression {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param line_number The line number of the token "extract" in the statement.
-   * @param column_number The column number of the token "extract in the statement.
-   * @param extract_field The field to extract.
-   * @param source_expression The expression to extract a field from.
-   */
-  ParseExtractFunction(const int line_number,
-                       const int column_number,
-                       ParseString *extract_field,
-                       ParseExpression *date_expression)
-      : ParseExpression(line_number, column_number),
-        extract_field_(extract_field),
-        date_expression_(date_expression) {
-  }
-
-  ExpressionType getExpressionType() const override {
-    return kExtract;
-  }
-
-  std::string getName() const override {
-    return "Extract";
-  }
-
-  /**
-   * @return The field to extract.
-   */
-  const ParseString* extract_field() const {
-    return extract_field_.get();
-  }
-
-  /**
-   * @return The expression to extract a field from.
-   */
-  const ParseExpression* date_expression() const {
-    return date_expression_.get();
-  }
-
-  std::string generateName() const override;
-
- protected:
-  void getFieldStringItems(
-      std::vector<std::string> *inline_field_names,
-      std::vector<std::string> *inline_field_values,
-      std::vector<std::string> *non_container_child_field_names,
-      std::vector<const ParseTreeNode*> *non_container_child_fields,
-      std::vector<std::string> *container_child_field_names,
-      std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const override;
-
- private:
-  std::unique_ptr<ParseString> extract_field_;
-  std::unique_ptr<ParseExpression> date_expression_;
-
-  DISALLOW_COPY_AND_ASSIGN(ParseExtractFunction);
-};
-
-
-/**
- * @brief Parsed representation of the substring function.
- */
-class ParseSubstringFunction : public ParseExpression {
- public:
-  static constexpr std::size_t kDefaultLength = std::numeric_limits<std::size_t>::max();
-
-  /**
-   * @brief Constructor.
-   *
-   * @param line_number The line number of the first token of the function call.
-   * @param column_number The column number of the first token of the function call.
-   * @param operand The operand of the substring.
-   * @param start_position The 1-based starting position of the substring.
-   * @param length Optional substring length.
-   */
-  ParseSubstringFunction(const int line_number,
-                         const int column_number,
-                         ParseExpression *operand,
-                         const std::size_t start_position,
-                         const std::size_t length = kDefaultLength)
-      : ParseExpression(line_number, column_number),
-        operand_(operand),
-        start_position_(start_position),
-        length_(length) {}
-
-  ExpressionType getExpressionType() const override {
-    return kSubstring;
-  }
-
-  std::string getName() const override {
-    return "Substring";
-  }
-
-  /**
-   * @return The operand of the substring.
-   */
-  const ParseExpression* operand() const {
-    return operand_.get();
-  }
-
-  /**
-   * @return The 1-based starting position of the substring.
-   */
-  std::size_t start_position() const {
-    return start_position_;
-  }
-
-  /**
-   * @return Then substring length.
-   */
-  std::size_t length() const {
-    return length_;
-  }
-
-  std::string generateName() const override;
-
- protected:
-  void getFieldStringItems(
-      std::vector<std::string> *inline_field_names,
-      std::vector<std::string> *inline_field_values,
-      std::vector<std::string> *non_container_child_field_names,
-      std::vector<const ParseTreeNode*> *non_container_child_fields,
-      std::vector<std::string> *container_child_field_names,
-      std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const override;
-
- private:
-  std::unique_ptr<ParseExpression> operand_;
-  const std::size_t start_position_;
-  const std::size_t length_;
-
-  DISALLOW_COPY_AND_ASSIGN(ParseSubstringFunction);
-};
-
 /** @} */
 
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/parser/ParseExpression.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseExpression.hpp b/parser/ParseExpression.hpp
index 1b9ade4..94b4487 100644
--- a/parser/ParseExpression.hpp
+++ b/parser/ParseExpression.hpp
@@ -39,14 +39,11 @@ class ParseExpression : public ParseTreeNode {
   enum ExpressionType {
     kAttribute,
     kBinaryExpression,
-    kExtract,
     kFunctionCall,
     kScalarLiteral,
     kSearchedCaseExpression,
     kSimpleCaseExpression,
     kSubqueryExpression,
-    kSubstring,
-    kUnaryExpression,
   };
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/583724ea/parser/SqlLexer.lpp
----------------------------------------------------------------------
diff --git a/parser/SqlLexer.lpp b/parser/SqlLexer.lpp
index c6402e0..a3f3238 100644
--- a/parser/SqlLexer.lpp
+++ b/parser/SqlLexer.lpp
@@ -184,6 +184,7 @@ unsigned_numeric_literal {exact_numeric_literal}|{approximate_numeric_literal}
   "blocksample"      return TOKEN_BLOCKSAMPLE;
   "bloomfilter"      return TOKEN_BLOOM_FILTER;
   "case"             return TOKEN_CASE;
+  "cast"             return TOKEN_CAST;
   "csbtree"          return TOKEN_CSB_TREE;
   "by"               return TOKEN_BY;
   "char"             return TOKEN_CHARACTER;


Mime
View raw message