quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sp...@apache.org
Subject [34/51] [abbrv] [partial] incubator-quickstep git commit: remove c++ files
Date Sun, 11 Dec 2016 17:45:57 GMT
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/scalar/ScalarLiteral.hpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarLiteral.hpp b/expressions/scalar/ScalarLiteral.hpp
deleted file mode 100644
index c7f5ceb..0000000
--- a/expressions/scalar/ScalarLiteral.hpp
+++ /dev/null
@@ -1,124 +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.
- **/
-
-#ifndef QUICKSTEP_EXPRESSIONS_SCALAR_SCALAR_LITERAL_HPP_
-#define QUICKSTEP_EXPRESSIONS_SCALAR_SCALAR_LITERAL_HPP_
-
-#include <utility>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/Expressions.pb.h"
-#include "expressions/scalar/Scalar.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "types/TypedValue.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class ColumnVector;
-class Type;
-class ValueAccessor;
-
-struct SubBlocksReference;
-
-/** \addtogroup Expressions
- *  @{
- */
-
-/**
- * @brief Scalars which are literal values from a SQL statement.
- **/
-class ScalarLiteral : public Scalar {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param lit A TypedValue to wrap.
-   * @param lit_type The Type that lit belongs to.
-   **/
-  ScalarLiteral(const TypedValue &lit,
-                const Type &lit_type)
-      : Scalar(lit_type),
-        internal_literal_(lit) {
-    internal_literal_.ensureNotReference();
-  }
-
-  ScalarLiteral(TypedValue &&lit,
-                const Type &lit_type)
-      : Scalar(lit_type),
-        internal_literal_(lit) {
-    internal_literal_.ensureNotReference();
-  }
-
-  ~ScalarLiteral() override {
-  }
-
-  serialization::Scalar getProto() const override;
-
-  Scalar* clone() const override;
-
-  ScalarDataSource getDataSource() const override {
-    return kLiteral;
-  }
-
-  TypedValue getValueForSingleTuple(const ValueAccessor &accessor,
-                                    const tuple_id tuple) const override {
-    return internal_literal_.makeReferenceToThis();
-  }
-
-  TypedValue getValueForJoinedTuples(
-      const ValueAccessor &left_accessor,
-      const relation_id left_relation_id,
-      const tuple_id left_tuple_id,
-      const ValueAccessor &right_accessor,
-      const relation_id right_relation_id,
-      const tuple_id right_tuple_id) const override {
-    return internal_literal_.makeReferenceToThis();
-  }
-
-  bool hasStaticValue() const override {
-    return true;
-  }
-
-  const TypedValue& getStaticValue() const override {
-    return internal_literal_;
-  }
-
-  ColumnVector* getAllValues(ValueAccessor *accessor,
-                             const SubBlocksReference *sub_blocks_ref) const override;
-
-  ColumnVector* getAllValuesForJoin(
-      const relation_id left_relation_id,
-      ValueAccessor *left_accessor,
-      const relation_id right_relation_id,
-      ValueAccessor *right_accessor,
-      const std::vector<std::pair<tuple_id, tuple_id>> &joined_tuple_ids) const override;
-
- private:
-  TypedValue internal_literal_;
-
-  DISALLOW_COPY_AND_ASSIGN(ScalarLiteral);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_EXPRESSIONS_SCALAR_SCALAR_LITERAL_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/scalar/ScalarUnaryExpression.cpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarUnaryExpression.cpp b/expressions/scalar/ScalarUnaryExpression.cpp
deleted file mode 100644
index 72fdbe1..0000000
--- a/expressions/scalar/ScalarUnaryExpression.cpp
+++ /dev/null
@@ -1,169 +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.
- **/
-
-#include "expressions/scalar/ScalarUnaryExpression.hpp"
-
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/Expressions.pb.h"
-#include "storage/ValueAccessor.hpp"
-#include "types/Type.hpp"
-#include "types/TypeErrors.hpp"
-#include "types/TypedValue.hpp"
-#include "types/containers/ColumnVector.hpp"
-#include "types/operations/Operation.pb.h"
-#include "types/operations/unary_operations/UnaryOperation.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())),
-      operation_(operation),
-      operand_(operand) {
-  initHelper(false);
-}
-
-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());
-
-  return proto;
-}
-
-Scalar* ScalarUnaryExpression::clone() const {
-  return new ScalarUnaryExpression(operation_, operand_->clone());
-}
-
-TypedValue ScalarUnaryExpression::getValueForSingleTuple(const ValueAccessor &accessor,
-                                                         const tuple_id tuple) const {
-  if (fast_operator_.get() == nullptr) {
-    return static_value_.makeReferenceToThis();
-  } else {
-    return fast_operator_->applyToTypedValue(operand_->getValueForSingleTuple(accessor, tuple));
-  }
-}
-
-TypedValue ScalarUnaryExpression::getValueForJoinedTuples(
-    const ValueAccessor &left_accessor,
-    const relation_id left_relation_id,
-    const tuple_id left_tuple_id,
-    const ValueAccessor &right_accessor,
-    const relation_id right_relation_id,
-    const tuple_id right_tuple_id) const {
-  if (fast_operator_.get() == nullptr) {
-    return static_value_.makeReferenceToThis();
-  } else {
-    return fast_operator_->applyToTypedValue(operand_->getValueForJoinedTuples(left_accessor,
-                                                                               left_relation_id,
-                                                                               left_tuple_id,
-                                                                               right_accessor,
-                                                                               right_relation_id,
-                                                                               right_tuple_id));
-  }
-}
-
-ColumnVector* ScalarUnaryExpression::getAllValues(
-    ValueAccessor *accessor,
-    const SubBlocksReference *sub_blocks_ref) const {
-  if (fast_operator_.get() == nullptr) {
-    return ColumnVector::MakeVectorOfValue(getType(),
-                                           static_value_,
-                                           accessor->getNumTuplesVirtual());
-  } else {
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-    const attribute_id operand_attr_id = operand_->getAttributeIdForValueAccessor();
-    if (operand_attr_id != -1) {
-      return fast_operator_->applyToValueAccessor(accessor, operand_attr_id);
-    }
-#endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-
-    std::unique_ptr<ColumnVector> operand_result(operand_->getAllValues(accessor, sub_blocks_ref));
-    return fast_operator_->applyToColumnVector(*operand_result);
-  }
-}
-
-ColumnVector* ScalarUnaryExpression::getAllValuesForJoin(
-    const relation_id left_relation_id,
-    ValueAccessor *left_accessor,
-    const relation_id right_relation_id,
-    ValueAccessor *right_accessor,
-    const std::vector<std::pair<tuple_id, tuple_id>> &joined_tuple_ids) const {
-  if (fast_operator_.get() == nullptr) {
-    return ColumnVector::MakeVectorOfValue(getType(),
-                                           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 fast_operator_->applyToValueAccessorForJoin(operand_accessor,
-                                                         using_left_relation,
-                                                         operand_attr_id,
-                                                         joined_tuple_ids);
-    }
-#endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_JOIN
-
-    std::unique_ptr<ColumnVector> operand_result(
-        operand_->getAllValuesForJoin(left_relation_id,
-                                      left_accessor,
-                                      right_relation_id,
-                                      right_accessor,
-                                      joined_tuple_ids));
-    return fast_operator_->applyToColumnVector(*operand_result);
-  }
-}
-
-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());
-  }
-}
-
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/scalar/ScalarUnaryExpression.hpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarUnaryExpression.hpp b/expressions/scalar/ScalarUnaryExpression.hpp
deleted file mode 100644
index 608a842..0000000
--- a/expressions/scalar/ScalarUnaryExpression.hpp
+++ /dev/null
@@ -1,125 +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.
- **/
-
-#ifndef QUICKSTEP_EXPRESSIONS_SCALAR_SCALAR_UNARY_EXPRESSION_HPP_
-#define QUICKSTEP_EXPRESSIONS_SCALAR_SCALAR_UNARY_EXPRESSION_HPP_
-
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/Expressions.pb.h"
-#include "expressions/scalar/Scalar.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "types/TypedValue.hpp"
-#include "types/operations/unary_operations/UnaryOperation.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class ColumnVector;
-class ValueAccessor;
-
-struct SubBlocksReference;
-
-/** \addtogroup Expressions
- *  @{
- */
-
-/**
- * @brief Expressions which are based on a UnaryOperation.
- **/
-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);
-
-  /**
-   * @brief Destructor.
-   **/
-  ~ScalarUnaryExpression() override {
-  }
-
-  serialization::Scalar getProto() const override;
-
-  Scalar* clone() const override;
-
-  ScalarDataSource getDataSource() const override {
-    return kUnaryExpression;
-  }
-
-  TypedValue getValueForSingleTuple(const ValueAccessor &accessor,
-                                    const tuple_id tuple) const override;
-
-  TypedValue getValueForJoinedTuples(
-      const ValueAccessor &left_accessor,
-      const relation_id left_relation_id,
-      const tuple_id left_tuple_id,
-      const ValueAccessor &right_accessor,
-      const relation_id right_relation_id,
-      const tuple_id right_tuple_id) const override;
-
-  bool hasStaticValue() const override {
-    return fast_operator_.get() == nullptr;
-  }
-
-  const TypedValue& getStaticValue() const override {
-    DCHECK(hasStaticValue());
-    return static_value_;
-  }
-
-  ColumnVector* getAllValues(ValueAccessor *accessor,
-                             const SubBlocksReference *sub_blocks_ref) const override;
-
-  ColumnVector* getAllValuesForJoin(
-      const relation_id left_relation_id,
-      ValueAccessor *left_accessor,
-      const relation_id right_relation_id,
-      ValueAccessor *right_accessor,
-      const std::vector<std::pair<tuple_id, tuple_id>> &joined_tuple_ids) const override;
-
- private:
-  void initHelper(bool own_children);
-
-  const UnaryOperation &operation_;
-
-  std::unique_ptr<Scalar> operand_;
-  TypedValue static_value_;
-  std::unique_ptr<UncheckedUnaryOperator> fast_operator_;
-
-  friend class PredicateTest;
-  friend class ScalarTest;
-
-  DISALLOW_COPY_AND_ASSIGN(ScalarUnaryExpression);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_EXPRESSIONS_SCALAR_SCALAR_UNARY_EXPRESSION_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/scalar/tests/ScalarCaseExpression_unittest.cpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/tests/ScalarCaseExpression_unittest.cpp b/expressions/scalar/tests/ScalarCaseExpression_unittest.cpp
deleted file mode 100644
index 2d1064b..0000000
--- a/expressions/scalar/tests/ScalarCaseExpression_unittest.cpp
+++ /dev/null
@@ -1,980 +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.
- **/
-
-#include <cstddef>
-#include <cstdio>
-#include <cstring>
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "catalog/CatalogAttribute.hpp"
-#include "catalog/CatalogRelation.hpp"
-#include "catalog/CatalogRelationSchema.hpp"
-#include "expressions/predicate/ComparisonPredicate.hpp"
-#include "expressions/predicate/ConjunctionPredicate.hpp"
-#include "expressions/predicate/DisjunctionPredicate.hpp"
-#include "expressions/predicate/Predicate.hpp"
-#include "expressions/scalar/Scalar.hpp"
-#include "expressions/scalar/ScalarAttribute.hpp"
-#include "expressions/scalar/ScalarBinaryExpression.hpp"
-#include "expressions/scalar/ScalarCaseExpression.hpp"
-#include "expressions/scalar/ScalarLiteral.hpp"
-#include "expressions/scalar/ScalarUnaryExpression.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "storage/TupleIdSequence.hpp"
-#include "storage/ValueAccessor.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.hpp"
-#include "types/TypedValue.hpp"
-#include "types/containers/ColumnVector.hpp"
-#include "types/containers/ColumnVectorsValueAccessor.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
-#include "types/operations/comparisons/ComparisonFactory.hpp"
-#include "types/operations/comparisons/ComparisonID.hpp"
-#include "types/operations/unary_operations/UnaryOperationFactory.hpp"
-#include "types/operations/unary_operations/UnaryOperationID.hpp"
-
-#include "gtest/gtest.h"
-
-// NetBSD's libc has snprintf(), but it doesn't show up in the std namespace
-// for C++.
-#ifndef __NetBSD__
-using std::snprintf;
-#endif
-
-namespace quickstep {
-
-class Type;
-
-class ScalarCaseExpressionTest : public ::testing::Test {
- protected:
-  static constexpr std::size_t kNumSampleTuples = 1000;
-
-  virtual void SetUp() {
-    sample_relation_.reset(new CatalogRelation(nullptr, "sample", 0));
-    sample_relation_->addAttribute(new CatalogAttribute(
-        sample_relation_.get(),
-        "int_attr",
-        TypeFactory::GetType(kInt, true)));
-    sample_relation_->addAttribute(new CatalogAttribute(
-        sample_relation_.get(),
-        "double_attr",
-        TypeFactory::GetType(kDouble, true)));
-    sample_relation_->addAttribute(new CatalogAttribute(
-        sample_relation_.get(),
-        "varchar_attr",
-        TypeFactory::GetType(kVarChar, 20, true)));
-
-    std::unique_ptr<NativeColumnVector> int_column(
-        new NativeColumnVector(TypeFactory::GetType(kInt, true), kNumSampleTuples));
-    std::unique_ptr<NativeColumnVector> double_column(
-        new NativeColumnVector(TypeFactory::GetType(kDouble, true), kNumSampleTuples));
-    std::unique_ptr<IndirectColumnVector> varchar_column(
-        new IndirectColumnVector(TypeFactory::GetType(kVarChar, 20, true), kNumSampleTuples));
-
-    for (std::size_t tuple_num = 0; tuple_num < kNumSampleTuples; ++tuple_num) {
-      if (tuple_num % 10 == 0) {
-        int_column->appendNullValue();
-      } else {
-        int int_value = tuple_num;
-        int_column->appendUntypedValue(&int_value);
-      }
-
-      if (tuple_num % 10 == 1) {
-        double_column->appendNullValue();
-      } else {
-        double double_value = -static_cast<double>(tuple_num);
-        double_column->appendUntypedValue(&double_value);
-      }
-
-      if (tuple_num % 10 == 2) {
-        TypedValue varchar_value(kVarChar);
-        varchar_column->appendTypedValue(std::move(varchar_value));
-      } else {
-        char varchar_buffer[20];
-        int written = snprintf(varchar_buffer,
-                               sizeof(varchar_buffer),
-                               "aa%05dzz",
-                               static_cast<int>(tuple_num));
-        ASSERT_LT(written, 20);
-        TypedValue varchar_value(kVarChar, varchar_buffer, std::strlen(varchar_buffer) + 1);
-        varchar_value.ensureNotReference();
-        varchar_column->appendTypedValue(std::move(varchar_value));
-      }
-    }
-
-    sample_data_value_accessor_.addColumn(int_column.release());
-    sample_data_value_accessor_.addColumn(double_column.release());
-    sample_data_value_accessor_.addColumn(varchar_column.release());
-  }
-
-  std::unique_ptr<CatalogRelation> sample_relation_;
-  ColumnVectorsValueAccessor sample_data_value_accessor_;
-};
-
-constexpr std::size_t ScalarCaseExpressionTest::kNumSampleTuples;
-
-// Test a CASE expression that always goes to the same branch.
-TEST_F(ScalarCaseExpressionTest, StaticBranchTest) {
-  std::vector<std::unique_ptr<Predicate>> when_predicates;
-  std::vector<std::unique_ptr<Scalar>> result_expressions;
-
-  const Type &int_type = TypeFactory::GetType(kInt);
-
-  // WHEN 1 > 2 THEN int_attr
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarLiteral(TypedValue(static_cast<int>(1)), int_type),
-      new ScalarLiteral(TypedValue(static_cast<int>(2)), int_type)));
-  result_expressions.emplace_back(
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)));
-
-  // WHEN 2 > 1 THEN 42
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarLiteral(TypedValue(static_cast<int>(2)), int_type),
-      new ScalarLiteral(TypedValue(static_cast<int>(1)), int_type)));
-  result_expressions.emplace_back(
-      new ScalarLiteral(TypedValue(static_cast<int>(42)), int_type));
-
-  // WHEN int_attr > 50 THEN -int_attr
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(static_cast<int>(50)), int_type)));
-  result_expressions.emplace_back(new ScalarUnaryExpression(
-      UnaryOperationFactory::GetUnaryOperation(UnaryOperationID::kNegate),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0))));
-
-  // ELSE 123
-  ScalarCaseExpression case_expr(
-      TypeFactory::GetType(kInt, true),
-      std::move(when_predicates),
-      std::move(result_expressions),
-      new ScalarLiteral(TypedValue(static_cast<int>(123)), int_type));
-
-  ASSERT_TRUE(case_expr.hasStaticValue());
-  ASSERT_EQ(kInt, case_expr.getStaticValue().getTypeID());
-  ASSERT_FALSE(case_expr.getStaticValue().isNull());
-  EXPECT_EQ(42, case_expr.getStaticValue().getLiteral<int>());
-}
-
-TEST_F(ScalarCaseExpressionTest, BasicComparisonAndLiteralTest) {
-  static const char kFirstLawString[]
-      = "A robot may not injure a human being or, through inaction, allow a "
-        "human being to come to harm.";
-  static const char kSecondLawString[]
-      = "A robot must obey orders given it by human beings except where such "
-        "orders would conflict with the First Law.";
-  static const char kThirdLawString[]
-      = "A robot must protect its own existence as long as such protection "
-        "does not conflict with the First or Second Law.";
-
-  std::vector<std::unique_ptr<Predicate>> when_predicates;
-  std::vector<std::unique_ptr<Scalar>> result_expressions;
-
-  const Type &int_type = TypeFactory::GetType(kInt);
-  const Type &double_type = TypeFactory::GetType(kDouble);
-  // Maximum length of 160 chars is longer than is needed for any of the
-  // sample strings.
-  const Type &varchar_type = TypeFactory::GetType(kVarChar, 160, false);
-
-  // WHEN int_attr < [kNumSampleTuples / 2] THEN [kFirstLawString]
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(static_cast<int>(kNumSampleTuples / 2)), int_type)));
-  result_expressions.emplace_back(new ScalarLiteral(
-      TypedValue(kVarChar, kFirstLawString, std::strlen(kFirstLawString) + 1),
-      varchar_type));
-
-  // WHEN double_attr > [-kNumSampleTuples * 3.0 / 4.0] THEN [kSecondLawString]
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarAttribute(*sample_relation_->getAttributeById(1)),
-      new ScalarLiteral(TypedValue(-static_cast<double>(kNumSampleTuples) * 3.0 / 4.0), double_type)));
-  result_expressions.emplace_back(new ScalarLiteral(
-      TypedValue(kVarChar, kSecondLawString, std::strlen(kSecondLawString) + 1),
-      varchar_type));
-
-  // ELSE [kThirdLawString]
-  ScalarCaseExpression case_expr(
-      TypeFactory::GetType(kVarChar, 160, false),
-      std::move(when_predicates),
-      std::move(result_expressions),
-      new ScalarLiteral(TypedValue(kVarChar, kThirdLawString, std::strlen(kThirdLawString) + 1),
-                        varchar_type));
-
-  std::unique_ptr<ColumnVector> result_cv(
-      case_expr.getAllValues(&sample_data_value_accessor_, nullptr));
-  ASSERT_FALSE(result_cv->isNative());
-  const IndirectColumnVector &indirect_result_cv
-      = static_cast<const IndirectColumnVector&>(*result_cv);
-  EXPECT_EQ(kNumSampleTuples, indirect_result_cv.size());
-
-  for (std::size_t tuple_num = 0;
-       tuple_num < indirect_result_cv.size();
-       ++tuple_num) {
-    if ((tuple_num % 10 != 0) && (tuple_num < kNumSampleTuples / 2)) {
-      EXPECT_STREQ(kFirstLawString,
-                   static_cast<const char*>(indirect_result_cv.getUntypedValue(tuple_num)));
-    } else if ((tuple_num % 10 != 1) && (tuple_num < kNumSampleTuples * 3 / 4)) {
-      EXPECT_STREQ(kSecondLawString,
-                   static_cast<const char*>(indirect_result_cv.getUntypedValue(tuple_num)));
-    } else {
-      EXPECT_STREQ(kThirdLawString,
-                   static_cast<const char*>(indirect_result_cv.getUntypedValue(tuple_num)));
-    }
-  }
-}
-
-// Same as above, but use a TupleIdSequenceAdapterValueAccessor that filters
-// the input.
-TEST_F(ScalarCaseExpressionTest, BasicComparisonAndLiteralWithFilteredInputTest) {
-  // Filter out every seventh tuple.
-  TupleIdSequence filter_sequence(kNumSampleTuples);
-  std::size_t num_filtered_tuples = 0;
-  for (std::size_t tuple_num = 0;
-       tuple_num < kNumSampleTuples;
-       ++tuple_num) {
-    if (tuple_num % 7 != 0) {
-      filter_sequence.set(tuple_num, true);
-      ++num_filtered_tuples;
-    }
-  }
-
-  std::unique_ptr<ValueAccessor> filtered_accessor(
-      sample_data_value_accessor_.createSharedTupleIdSequenceAdapter(filter_sequence));
-
-  static const char kFirstLawString[]
-      = "A robot may not injure a human being or, through inaction, allow a "
-        "human being to come to harm.";
-  static const char kSecondLawString[]
-      = "A robot must obey orders given it by human beings except where such "
-        "orders would conflict with the First Law.";
-  static const char kThirdLawString[]
-      = "A robot must protect its own existence as long as such protection "
-        "does not conflict with the First or Second Law.";
-
-  std::vector<std::unique_ptr<Predicate>> when_predicates;
-  std::vector<std::unique_ptr<Scalar>> result_expressions;
-
-  const Type &int_type = TypeFactory::GetType(kInt);
-  const Type &double_type = TypeFactory::GetType(kDouble);
-  const Type &varchar_type = TypeFactory::GetType(kVarChar, 160, false);
-
-  // WHEN int_attr < [kNumSampleTuples / 2] THEN [kFirstLawString]
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(static_cast<int>(kNumSampleTuples / 2)), int_type)));
-  result_expressions.emplace_back(new ScalarLiteral(
-      TypedValue(kVarChar, kFirstLawString, std::strlen(kFirstLawString) + 1),
-      varchar_type));
-
-  // WHEN double_attr > [kNumSampleTuples * 3.0 / 4.0] THEN [kSecondLawString]
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarAttribute(*sample_relation_->getAttributeById(1)),
-      new ScalarLiteral(TypedValue(-static_cast<double>(kNumSampleTuples) * 3.0 / 4.0),
-                        double_type)));
-  result_expressions.emplace_back(new ScalarLiteral(
-      TypedValue(kVarChar, kSecondLawString, std::strlen(kSecondLawString) + 1),
-      varchar_type));
-
-  // ELSE [kThirdLawString]
-  ScalarCaseExpression case_expr(
-      TypeFactory::GetType(kVarChar, 160, false),
-      std::move(when_predicates),
-      std::move(result_expressions),
-      new ScalarLiteral(TypedValue(kVarChar, kThirdLawString, std::strlen(kThirdLawString) + 1),
-                        varchar_type));
-
-  std::unique_ptr<ColumnVector> result_cv(
-      case_expr.getAllValues(filtered_accessor.get(), nullptr));
-  ASSERT_FALSE(result_cv->isNative());
-  const IndirectColumnVector &indirect_result_cv
-      = static_cast<const IndirectColumnVector&>(*result_cv);
-  EXPECT_EQ(num_filtered_tuples, indirect_result_cv.size());
-
-  std::size_t original_tuple_num = 0;
-  for (std::size_t tuple_num = 0;
-       tuple_num < indirect_result_cv.size();
-       ++tuple_num, ++original_tuple_num) {
-    if (original_tuple_num % 7 == 0) {
-      ++original_tuple_num;
-    }
-
-    if ((original_tuple_num % 10 != 0) && (original_tuple_num < kNumSampleTuples / 2)) {
-      EXPECT_STREQ(kFirstLawString,
-                   static_cast<const char*>(indirect_result_cv.getUntypedValue(tuple_num)));
-    } else if ((original_tuple_num % 10 != 1) && (original_tuple_num < kNumSampleTuples * 3 / 4)) {
-      EXPECT_STREQ(kSecondLawString,
-                   static_cast<const char*>(indirect_result_cv.getUntypedValue(tuple_num)));
-    } else {
-      EXPECT_STREQ(kThirdLawString,
-                   static_cast<const char*>(indirect_result_cv.getUntypedValue(tuple_num)));
-    }
-  }
-}
-
-// If a tuple matches multiple WHEN clauses, get the value from the first one.
-TEST_F(ScalarCaseExpressionTest, WhenClauseOrderTest) {
-  static const char kFirstLawString[]
-      = "A robot may not injure a human being or, through inaction, allow a "
-        "human being to come to harm.";
-  static const char kSecondLawString[]
-      = "A robot must obey orders given it by human beings except where such "
-        "orders would conflict with the First Law.";
-  static const char kThirdLawString[]
-      = "A robot must protect its own existence as long as such protection "
-        "does not conflict with the First or Second Law.";
-
-  std::vector<std::unique_ptr<Predicate>> when_predicates;
-  std::vector<std::unique_ptr<Scalar>> result_expressions;
-
-  const Type &int_type = TypeFactory::GetType(kInt);
-  const Type &varchar_type = TypeFactory::GetType(kVarChar, 160, false);
-
-  // WHEN int_attr < 500 THEN [kFirstLawString]
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(static_cast<int>(500)), int_type)));
-  result_expressions.emplace_back(new ScalarLiteral(
-      TypedValue(kVarChar, kFirstLawString, std::strlen(kFirstLawString) + 1),
-      varchar_type));
-
-  // WHEN int_attr < 750 THEN [kSecondLawString]
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(static_cast<int>(750)), int_type)));
-  result_expressions.emplace_back(new ScalarLiteral(
-      TypedValue(kVarChar, kSecondLawString, std::strlen(kSecondLawString) + 1),
-      varchar_type));
-
-  // ELSE [kThirdLawString]
-  ScalarCaseExpression case_expr(
-      TypeFactory::GetType(kVarChar, 160, false),
-      std::move(when_predicates),
-      std::move(result_expressions),
-      new ScalarLiteral(TypedValue(kVarChar, kThirdLawString, std::strlen(kThirdLawString) + 1),
-                        varchar_type));
-
-  std::unique_ptr<ColumnVector> result_cv(
-      case_expr.getAllValues(&sample_data_value_accessor_, nullptr));
-  ASSERT_FALSE(result_cv->isNative());
-  const IndirectColumnVector &indirect_result_cv
-      = static_cast<const IndirectColumnVector&>(*result_cv);
-  EXPECT_EQ(kNumSampleTuples, indirect_result_cv.size());
-
-  for (std::size_t tuple_num = 0;
-       tuple_num < indirect_result_cv.size();
-       ++tuple_num) {
-    if ((tuple_num % 10 != 0) && (tuple_num < 500)) {
-      EXPECT_STREQ(kFirstLawString,
-                   static_cast<const char*>(indirect_result_cv.getUntypedValue(tuple_num)));
-    } else if ((tuple_num % 10 != 0) && (tuple_num < 750)) {
-      EXPECT_STREQ(kSecondLawString,
-                   static_cast<const char*>(indirect_result_cv.getUntypedValue(tuple_num)));
-    } else {
-      EXPECT_STREQ(kThirdLawString,
-                   static_cast<const char*>(indirect_result_cv.getUntypedValue(tuple_num)));
-    }
-  }
-}
-
-TEST_F(ScalarCaseExpressionTest, ComplexConjunctionAndCalculatedExpressionTest) {
-  const Type &int_type = TypeFactory::GetType(kInt);
-  const Type &varchar_type = TypeFactory::GetType(kVarChar, 20, false);
-
-  std::vector<std::unique_ptr<Predicate>> when_predicates;
-  std::vector<std::unique_ptr<Scalar>> result_expressions;
-
-  // WHEN (int_attr * 2) + double_attr < 500 AND varchar_attr > 'aa002'
-  // THEN -int_attr
-  static const char kStringLit1[] = "aa002";
-  ConjunctionPredicate *first_case_predicate = new ConjunctionPredicate();
-  first_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarBinaryExpression(
-          BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd),
-          new ScalarBinaryExpression(
-              BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply),
-              new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-              new ScalarLiteral(TypedValue(2), int_type)),
-          new ScalarAttribute(*sample_relation_->getAttributeById(1))),
-      new ScalarLiteral(TypedValue(static_cast<int>(kNumSampleTuples / 2)), int_type)));
-  first_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarAttribute(*sample_relation_->getAttributeById(2)),
-      new ScalarLiteral(TypedValue(kVarChar, kStringLit1, std::strlen(kStringLit1) + 1), varchar_type)));
-  when_predicates.emplace_back(first_case_predicate);
-
-  result_expressions.emplace_back(new ScalarUnaryExpression(
-      UnaryOperationFactory::GetUnaryOperation(UnaryOperationID::kNegate),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0))));
-
-  // WHEN int_attr >= 50 AND (CASE WHEN varchar_attr < 'aa007' THEN 1 ELSE -1) > 0
-  // THEN int_attr + 10
-  static const char kStringLit2[] = "aa007";
-  ConjunctionPredicate *second_case_predicate = new ConjunctionPredicate();
-  second_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreaterOrEqual),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(50), int_type)));
-  std::vector<std::unique_ptr<Predicate>> subcase_preds;
-  subcase_preds.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(2)),
-      new ScalarLiteral(TypedValue(kVarChar, kStringLit2, std::strlen(kStringLit2) + 1), varchar_type)));
-  std::vector<std::unique_ptr<Scalar>> subcase_results;
-  subcase_results.emplace_back(new ScalarLiteral(TypedValue(1), int_type));
-  second_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarCaseExpression(
-          TypeFactory::GetType(kInt, false),
-          std::move(subcase_preds),
-          std::move(subcase_results),
-          new ScalarLiteral(TypedValue(-1), int_type)),
-      new ScalarLiteral(TypedValue(0), int_type)));
-  when_predicates.emplace_back(second_case_predicate);
-
-  result_expressions.emplace_back(new ScalarBinaryExpression(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(10), int_type)));
-
-  // ELSE 5 * int_attr
-  ScalarCaseExpression case_expr(
-      TypeFactory::GetType(kInt, true),
-      std::move(when_predicates),
-      std::move(result_expressions),
-      new ScalarBinaryExpression(
-          BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply),
-          new ScalarLiteral(TypedValue(5), int_type),
-          new ScalarAttribute(*sample_relation_->getAttributeById(0))));
-
-  std::unique_ptr<ColumnVector> result_cv(
-      case_expr.getAllValues(&sample_data_value_accessor_, nullptr));
-  ASSERT_TRUE(result_cv->isNative());
-  const NativeColumnVector &native_result_cv
-      = static_cast<const NativeColumnVector&>(*result_cv);
-  EXPECT_EQ(kNumSampleTuples, native_result_cv.size());
-
-  for (std::size_t tuple_num = 0;
-       tuple_num < native_result_cv.size();
-       ++tuple_num) {
-    if ((tuple_num % 10 != 0)
-        && (tuple_num % 10 != 1)
-        && (tuple_num % 10 != 2)
-        && (tuple_num < 500)
-        && (tuple_num >= 200)) {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(-static_cast<int>(tuple_num),
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    } else if ((tuple_num % 10 != 0)
-               && (tuple_num % 10 != 2)
-               && (tuple_num >= 50 && tuple_num < 700)) {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(static_cast<int>(tuple_num) + 10,
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    } else if (tuple_num % 10 == 0) {
-      EXPECT_EQ(nullptr, native_result_cv.getUntypedValue(tuple_num));
-    } else {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(static_cast<int>(tuple_num) * 5,
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    }
-  }
-}
-
-// Same as above, but use a TupleIdSequenceAdapterValueAccessor that filters
-// the input.
-TEST_F(ScalarCaseExpressionTest,
-       ComplexConjunctionAndCalculatedExpressionWithFilteredInputTest) {
-  // Filter out every seventh tuple.
-  TupleIdSequence filter_sequence(kNumSampleTuples);
-  std::size_t num_filtered_tuples = 0;
-  for (std::size_t tuple_num = 0;
-       tuple_num < kNumSampleTuples;
-       ++tuple_num) {
-    if (tuple_num % 7 != 0) {
-      filter_sequence.set(tuple_num, true);
-      ++num_filtered_tuples;
-    }
-  }
-
-  std::unique_ptr<ValueAccessor> filtered_accessor(
-      sample_data_value_accessor_.createSharedTupleIdSequenceAdapter(filter_sequence));
-
-  std::vector<std::unique_ptr<Predicate>> when_predicates;
-  std::vector<std::unique_ptr<Scalar>> result_expressions;
-
-  const Type &int_type = TypeFactory::GetType(kInt);
-  const Type &varchar_type = TypeFactory::GetType(kVarChar, 20, false);
-
-  // WHEN (int_attr * 2) + double_attr < 500 AND varchar_attr > 'aa002'
-  // THEN -int_attr
-  static const char kStringLit1[] = "aa002";
-  ConjunctionPredicate *first_case_predicate = new ConjunctionPredicate();
-  first_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarBinaryExpression(
-          BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd),
-          new ScalarBinaryExpression(
-              BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply),
-              new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-              new ScalarLiteral(TypedValue(2), int_type)),
-          new ScalarAttribute(*sample_relation_->getAttributeById(1))),
-      new ScalarLiteral(TypedValue(static_cast<int>(kNumSampleTuples / 2)), int_type)));
-  first_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarAttribute(*sample_relation_->getAttributeById(2)),
-      new ScalarLiteral(TypedValue(kVarChar, kStringLit1, std::strlen(kStringLit1) + 1), varchar_type)));
-  when_predicates.emplace_back(first_case_predicate);
-
-  result_expressions.emplace_back(new ScalarUnaryExpression(
-      UnaryOperationFactory::GetUnaryOperation(UnaryOperationID::kNegate),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0))));
-
-  // WHEN int_attr >= 50 AND (CASE WHEN varchar_attr < 'aa007' THEN 1 ELSE -1) > 0
-  // THEN int_attr + 10
-  static const char kStringLit2[] = "aa007";
-  ConjunctionPredicate *second_case_predicate = new ConjunctionPredicate();
-  second_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreaterOrEqual),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(50), int_type)));
-  std::vector<std::unique_ptr<Predicate>> subcase_preds;
-  subcase_preds.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(2)),
-      new ScalarLiteral(TypedValue(kVarChar, kStringLit2, std::strlen(kStringLit2) + 1), varchar_type)));
-  std::vector<std::unique_ptr<Scalar>> subcase_results;
-  subcase_results.emplace_back(new ScalarLiteral(TypedValue(1), int_type));
-  second_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarCaseExpression(
-          TypeFactory::GetType(kInt, false),
-          std::move(subcase_preds),
-          std::move(subcase_results),
-          new ScalarLiteral(TypedValue(-1), int_type)),
-      new ScalarLiteral(TypedValue(0), int_type)));
-  when_predicates.emplace_back(second_case_predicate);
-
-  result_expressions.emplace_back(new ScalarBinaryExpression(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(10), int_type)));
-
-  // ELSE 5 * int_attr
-  ScalarCaseExpression case_expr(
-      TypeFactory::GetType(kInt, true),
-      std::move(when_predicates),
-      std::move(result_expressions),
-      new ScalarBinaryExpression(
-          BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply),
-          new ScalarLiteral(TypedValue(5), int_type),
-          new ScalarAttribute(*sample_relation_->getAttributeById(0))));
-
-  std::unique_ptr<ColumnVector> result_cv(
-      case_expr.getAllValues(filtered_accessor.get(), nullptr));
-  ASSERT_TRUE(result_cv->isNative());
-  const NativeColumnVector &native_result_cv
-      = static_cast<const NativeColumnVector&>(*result_cv);
-  EXPECT_EQ(num_filtered_tuples, native_result_cv.size());
-
-  std::size_t original_tuple_num = 0;
-  for (std::size_t tuple_num = 0;
-       tuple_num < native_result_cv.size();
-       ++tuple_num, ++original_tuple_num) {
-    if (original_tuple_num % 7 == 0) {
-      ++original_tuple_num;
-    }
-
-    if ((original_tuple_num % 10 != 0)
-        && (original_tuple_num % 10 != 1)
-        && (original_tuple_num % 10 != 2)
-        && (original_tuple_num < 500)
-        && (original_tuple_num >= 200)) {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(-static_cast<int>(original_tuple_num),
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    } else if ((original_tuple_num % 10 != 0)
-               && (original_tuple_num % 10 != 2)
-               && (original_tuple_num >= 50 && original_tuple_num < 700)) {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(static_cast<int>(original_tuple_num) + 10,
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    } else if (original_tuple_num % 10 == 0) {
-      EXPECT_EQ(nullptr, native_result_cv.getUntypedValue(tuple_num));
-    } else {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(static_cast<int>(original_tuple_num) * 5,
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    }
-  }
-}
-
-TEST_F(ScalarCaseExpressionTest, ComplexDisjunctionAndCalculatedExpressionTest) {
-  const Type &int_type = TypeFactory::GetType(kInt);
-  const Type &varchar_type = TypeFactory::GetType(kVarChar, 20, false);
-
-  std::vector<std::unique_ptr<Predicate>> when_predicates;
-  std::vector<std::unique_ptr<Scalar>> result_expressions;
-
-  // WHEN (int_attr * 2) + double_attr > 750 OR varchar_attr < 'aa002'
-  // THEN -int_attr
-  static const char kStringLit1[] = "aa002";
-  DisjunctionPredicate *first_case_predicate = new DisjunctionPredicate();
-  first_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarBinaryExpression(
-          BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd),
-          new ScalarBinaryExpression(
-              BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply),
-              new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-              new ScalarLiteral(TypedValue(2), int_type)),
-          new ScalarAttribute(*sample_relation_->getAttributeById(1))),
-      new ScalarLiteral(TypedValue(750), int_type)));
-  first_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(2)),
-      new ScalarLiteral(TypedValue(kVarChar, kStringLit1, std::strlen(kStringLit1) + 1), varchar_type)));
-  when_predicates.emplace_back(first_case_predicate);
-
-  result_expressions.emplace_back(new ScalarUnaryExpression(
-      UnaryOperationFactory::GetUnaryOperation(UnaryOperationID::kNegate),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0))));
-
-  // WHEN int_attr < 350 OR (CASE WHEN varchar_attr < 'aa006' THEN 1 ELSE -1) < 0
-  // THEN int_attr + 10
-  static const char kStringLit2[] = "aa006";
-  DisjunctionPredicate *second_case_predicate = new DisjunctionPredicate();
-  second_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(350), int_type)));
-  std::vector<std::unique_ptr<Predicate>> subcase_preds;
-  subcase_preds.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(2)),
-      new ScalarLiteral(TypedValue(kVarChar, kStringLit2, std::strlen(kStringLit2) + 1), varchar_type)));
-  std::vector<std::unique_ptr<Scalar>> subcase_results;
-  subcase_results.emplace_back(new ScalarLiteral(TypedValue(1), int_type));
-  second_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarCaseExpression(
-          TypeFactory::GetType(kInt, false),
-          std::move(subcase_preds),
-          std::move(subcase_results),
-          new ScalarLiteral(TypedValue(-1), int_type)),
-      new ScalarLiteral(TypedValue(0), int_type)));
-  when_predicates.emplace_back(second_case_predicate);
-
-  result_expressions.emplace_back(new ScalarBinaryExpression(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(10), int_type)));
-
-  // ELSE 5 * int_attr
-  ScalarCaseExpression case_expr(
-      TypeFactory::GetType(kInt, true),
-      std::move(when_predicates),
-      std::move(result_expressions),
-      new ScalarBinaryExpression(
-          BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply),
-          new ScalarLiteral(TypedValue(5), int_type),
-          new ScalarAttribute(*sample_relation_->getAttributeById(0))));
-
-  std::unique_ptr<ColumnVector> result_cv(
-      case_expr.getAllValues(&sample_data_value_accessor_, nullptr));
-  ASSERT_TRUE(result_cv->isNative());
-  const NativeColumnVector &native_result_cv
-      = static_cast<const NativeColumnVector&>(*result_cv);
-  EXPECT_EQ(kNumSampleTuples, native_result_cv.size());
-
-  for (std::size_t tuple_num = 0;
-       tuple_num < native_result_cv.size();
-       ++tuple_num) {
-    if (tuple_num % 10 == 0) {
-      EXPECT_EQ(nullptr, native_result_cv.getUntypedValue(tuple_num));
-    } else if (((tuple_num % 10 != 1) && (tuple_num > 750))
-               || ((tuple_num % 10 != 2) && (tuple_num < 200))) {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(-static_cast<int>(tuple_num),
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    } else if ((tuple_num < 350)
-               || (tuple_num % 10 == 2)
-               || ((tuple_num % 10 != 2) && (tuple_num >= 600))) {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(static_cast<int>(tuple_num) + 10,
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    } else {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(static_cast<int>(tuple_num) * 5,
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    }
-  }
-}
-
-// Same as above, but use a TupleIdSequenceAdapterValueAccessor that filters
-// the input.
-TEST_F(ScalarCaseExpressionTest,
-       ComplexDisjunctionAndCalculatedExpressionWithFilteredInputTest) {
-  const Type &int_type = TypeFactory::GetType(kInt);
-  const Type &varchar_type = TypeFactory::GetType(kVarChar, 20, false);
-
-  // Filter out every seventh tuple.
-  TupleIdSequence filter_sequence(kNumSampleTuples);
-  std::size_t num_filtered_tuples = 0;
-  for (std::size_t tuple_num = 0;
-       tuple_num < kNumSampleTuples;
-       ++tuple_num) {
-    if (tuple_num % 7 != 0) {
-      filter_sequence.set(tuple_num, true);
-      ++num_filtered_tuples;
-    }
-  }
-
-  std::unique_ptr<ValueAccessor> filtered_accessor(
-      sample_data_value_accessor_.createSharedTupleIdSequenceAdapter(filter_sequence));
-
-  std::vector<std::unique_ptr<Predicate>> when_predicates;
-  std::vector<std::unique_ptr<Scalar>> result_expressions;
-
-  // WHEN (int_attr * 2) + double_attr > 750 OR varchar_attr < 'aa002'
-  // THEN -int_attr
-  static const char kStringLit1[] = "aa002";
-  DisjunctionPredicate *first_case_predicate = new DisjunctionPredicate();
-  first_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarBinaryExpression(
-          BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd),
-          new ScalarBinaryExpression(
-              BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply),
-              new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-              new ScalarLiteral(TypedValue(2), int_type)),
-          new ScalarAttribute(*sample_relation_->getAttributeById(1))),
-      new ScalarLiteral(TypedValue(750), int_type)));
-  first_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(2)),
-      new ScalarLiteral(TypedValue(kVarChar, kStringLit1, std::strlen(kStringLit1) + 1), varchar_type)));
-  when_predicates.emplace_back(first_case_predicate);
-
-  result_expressions.emplace_back(new ScalarUnaryExpression(
-      UnaryOperationFactory::GetUnaryOperation(UnaryOperationID::kNegate),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0))));
-
-  // WHEN int_attr < 350 OR (CASE WHEN varchar_attr < 'aa006' THEN 1 ELSE -1) < 0
-  // THEN int_attr + 10
-  static const char kStringLit2[] = "aa006";
-  DisjunctionPredicate *second_case_predicate = new DisjunctionPredicate();
-  second_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(350), int_type)));
-  std::vector<std::unique_ptr<Predicate>> subcase_preds;
-  subcase_preds.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(2)),
-      new ScalarLiteral(TypedValue(kVarChar, kStringLit2, std::strlen(kStringLit2) + 1), varchar_type)));
-  std::vector<std::unique_ptr<Scalar>> subcase_results;
-  subcase_results.emplace_back(new ScalarLiteral(TypedValue(1), int_type));
-  second_case_predicate->addPredicate(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarCaseExpression(
-          TypeFactory::GetType(kInt, false),
-          std::move(subcase_preds),
-          std::move(subcase_results),
-          new ScalarLiteral(TypedValue(-1), int_type)),
-      new ScalarLiteral(TypedValue(0), int_type)));
-  when_predicates.emplace_back(second_case_predicate);
-
-  result_expressions.emplace_back(new ScalarBinaryExpression(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarLiteral(TypedValue(10), int_type)));
-
-  // ELSE 5 * int_attr
-  ScalarCaseExpression case_expr(
-      TypeFactory::GetType(kInt, true),
-      std::move(when_predicates),
-      std::move(result_expressions),
-      new ScalarBinaryExpression(
-          BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply),
-          new ScalarLiteral(TypedValue(5), int_type),
-          new ScalarAttribute(*sample_relation_->getAttributeById(0))));
-
-  std::unique_ptr<ColumnVector> result_cv(
-      case_expr.getAllValues(filtered_accessor.get(), nullptr));
-  ASSERT_TRUE(result_cv->isNative());
-  const NativeColumnVector &native_result_cv
-      = static_cast<const NativeColumnVector&>(*result_cv);
-  EXPECT_EQ(num_filtered_tuples, native_result_cv.size());
-
-  std::size_t original_tuple_num = 0;
-  for (std::size_t tuple_num = 0;
-       tuple_num < native_result_cv.size();
-       ++tuple_num, ++original_tuple_num) {
-    if (original_tuple_num % 7 == 0) {
-      ++original_tuple_num;
-    }
-
-    if (original_tuple_num % 10 == 0) {
-      EXPECT_EQ(nullptr, native_result_cv.getUntypedValue(tuple_num));
-    } else if (((original_tuple_num % 10 != 1) && (original_tuple_num > 750))
-               || ((original_tuple_num % 10 != 2) && (original_tuple_num < 200))) {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(-static_cast<int>(original_tuple_num),
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    } else if ((original_tuple_num < 350)
-               || (original_tuple_num % 10 == 2)
-               || ((original_tuple_num % 10 != 2) && (original_tuple_num >= 600))) {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(static_cast<int>(original_tuple_num) + 10,
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    } else {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(tuple_num));
-      EXPECT_EQ(static_cast<int>(original_tuple_num) * 5,
-                *static_cast<const int*>(native_result_cv.getUntypedValue(tuple_num)));
-    }
-  }
-}
-
-// Test CASE evaluation over joins, with both WHEN predicates and THEN
-// expressions referencing attributes in both relations.
-TEST_F(ScalarCaseExpressionTest, JoinTest) {
-  // Simulate a join with another relation.
-  CatalogRelation other_relation(nullptr, "other", 1);
-  other_relation.addAttribute(new CatalogAttribute(&other_relation,
-                                                   "other_double",
-                                                   TypeFactory::GetType(kDouble, false)));
-  other_relation.addAttribute(new CatalogAttribute(&other_relation,
-                                                   "other_int",
-                                                   TypeFactory::GetType(kInt, false)));
-
-  static const double kOtherDoubleValues[] = {-250.0, -750.0};
-  std::unique_ptr<NativeColumnVector> other_double_column(
-      new NativeColumnVector(TypeFactory::GetType(kDouble, false), 2));
-  other_double_column->appendUntypedValue(kOtherDoubleValues);
-  other_double_column->appendUntypedValue(kOtherDoubleValues + 1);
-
-  static const int kOtherIntValues[] = {10, -1};
-  std::unique_ptr<NativeColumnVector> other_int_column(
-      new NativeColumnVector(TypeFactory::GetType(kInt, false), 2));
-  other_int_column->appendUntypedValue(kOtherIntValues);
-  other_int_column->appendUntypedValue(kOtherIntValues + 1);
-
-  ColumnVectorsValueAccessor other_accessor;
-  other_accessor.addColumn(other_double_column.release());
-  other_accessor.addColumn(other_int_column.release());
-
-  // Setup expression.
-  std::vector<std::unique_ptr<Predicate>> when_predicates;
-  std::vector<std::unique_ptr<Scalar>> result_expressions;
-
-  // WHEN double_attr > other_double THEN int_attr + other_int
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kGreater),
-      new ScalarAttribute(*sample_relation_->getAttributeById(1)),
-      new ScalarAttribute(*other_relation.getAttributeById(0))));
-  result_expressions.emplace_back(new ScalarBinaryExpression(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarAttribute(*other_relation.getAttributeById(1))));
-
-  // WHEN double_attr < other_double THEN int_attr * other_int
-  when_predicates.emplace_back(new ComparisonPredicate(
-      ComparisonFactory::GetComparison(ComparisonID::kLess),
-      new ScalarAttribute(*sample_relation_->getAttributeById(1)),
-      new ScalarAttribute(*other_relation.getAttributeById(0))));
-  result_expressions.emplace_back(new ScalarBinaryExpression(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply),
-      new ScalarAttribute(*sample_relation_->getAttributeById(0)),
-      new ScalarAttribute(*other_relation.getAttributeById(1))));
-
-  // ELSE 0
-  ScalarCaseExpression case_expr(
-      TypeFactory::GetType(kInt, true),
-      std::move(when_predicates),
-      std::move(result_expressions),
-      new ScalarLiteral(TypedValue(0), TypeFactory::GetType(kInt)));
-
-  // Create a list of joined tuple-id pairs (just the cross-product of tuples).
-  std::vector<std::pair<tuple_id, tuple_id>> joined_tuple_ids;
-  for (std::size_t tuple_num = 0; tuple_num < kNumSampleTuples; ++tuple_num) {
-    joined_tuple_ids.emplace_back(tuple_num, 0);
-    joined_tuple_ids.emplace_back(tuple_num, 1);
-  }
-
-  std::unique_ptr<ColumnVector> result_cv(case_expr.getAllValuesForJoin(
-      0,
-      &sample_data_value_accessor_,
-      1,
-      &other_accessor,
-      joined_tuple_ids));
-  ASSERT_TRUE(result_cv->isNative());
-  const NativeColumnVector &native_result_cv
-      = static_cast<const NativeColumnVector&>(*result_cv);
-  EXPECT_EQ(kNumSampleTuples * 2, native_result_cv.size());
-
-  for (std::size_t result_num = 0;
-       result_num < native_result_cv.size();
-       ++result_num) {
-    // For convenience, calculate expected tuple values here.
-    const bool sample_int_null = ((result_num >> 1) % 10 == 0);
-    const int sample_int = result_num >> 1;
-    const bool sample_double_null = ((result_num >> 1) % 10 == 1);
-    const double sample_double = -static_cast<double>(result_num >> 1);
-    const int other_int = kOtherIntValues[result_num & 0x1];
-    const double other_double = kOtherDoubleValues[result_num & 0x1];
-
-    if (sample_double_null) {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(result_num));
-      EXPECT_EQ(0, *static_cast<const int*>(native_result_cv.getUntypedValue(result_num)));
-    } else if (sample_double > other_double) {
-      if (sample_int_null) {
-        EXPECT_EQ(nullptr, native_result_cv.getUntypedValue(result_num));
-      } else {
-        ASSERT_NE(nullptr, native_result_cv.getUntypedValue(result_num));
-        EXPECT_EQ(sample_int + other_int,
-                  *static_cast<const int*>(native_result_cv.getUntypedValue(result_num)));
-      }
-    } else if (sample_double < other_double) {
-      if (sample_int_null) {
-        EXPECT_EQ(nullptr, native_result_cv.getUntypedValue(result_num));
-      } else {
-        ASSERT_NE(nullptr, native_result_cv.getUntypedValue(result_num));
-        EXPECT_EQ(sample_int * other_int,
-                  *static_cast<const int*>(native_result_cv.getUntypedValue(result_num)));
-      }
-    } else {
-      ASSERT_NE(nullptr, native_result_cv.getUntypedValue(result_num));
-      EXPECT_EQ(0, *static_cast<const int*>(native_result_cv.getUntypedValue(result_num)));
-    }
-  }
-}
-
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/scalar/tests/Scalar_unittest.cpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/tests/Scalar_unittest.cpp b/expressions/scalar/tests/Scalar_unittest.cpp
deleted file mode 100644
index 8e106bb..0000000
--- a/expressions/scalar/tests/Scalar_unittest.cpp
+++ /dev/null
@@ -1,381 +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.
- **/
-
-#include <cstddef>
-#include <cstdint>
-#include <cstring>
-#include <limits>
-#include <memory>
-#include <string>
-
-#include "gtest/gtest.h"
-
-#include "catalog/CatalogAttribute.hpp"
-#include "catalog/CatalogDatabase.hpp"
-#include "catalog/CatalogRelation.hpp"
-#include "expressions/ExpressionFactories.hpp"
-#include "expressions/scalar/Scalar.hpp"
-#include "expressions/scalar/ScalarAttribute.hpp"
-#include "expressions/scalar/ScalarBinaryExpression.hpp"
-#include "expressions/scalar/ScalarLiteral.hpp"
-#include "expressions/scalar/ScalarUnaryExpression.hpp"
-#include "types/DatetimeLit.hpp"
-#include "types/IntervalLit.hpp"
-#include "types/Type.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.hpp"
-#include "types/TypedValue.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/unary_operations/NumericCastOperation.hpp"
-#include "types/operations/unary_operations/UnaryOperation.hpp"
-#include "types/operations/unary_operations/UnaryOperationFactory.hpp"
-#include "types/operations/unary_operations/UnaryOperationID.hpp"
-#include "utility/Macros.hpp"
-
-using std::int64_t;
-using std::numeric_limits;
-using std::size_t;
-using std::string;
-using std::strlen;
-using std::unique_ptr;
-
-namespace quickstep {
-
-namespace {
-
-static const char kSampleStringShort[] = "foo";
-
-static const char kSampleStringLong[] =
-    "Space is big. You just won't believe how vastly, hugely, mind-bogglingly "
-    "big it is. I mean, you may think it's a long way down the road to the "
-    "chemist's, but that's just peanuts to space.";
-
-}  // namespace
-
-class ScalarTest : public ::testing::Test {
- protected:
-  virtual void SetUp() {
-    database_.reset(new CatalogDatabase(NULL, "database_"));
-
-    rel_numeric_ = createCatalogRelation("rel_numeric_");
-    attr_int_ = createCatalogAttribute(rel_numeric_, "attr_int", TypeFactory::GetType(kInt));
-    attr_long_ = createCatalogAttribute(rel_numeric_, "attr_long", TypeFactory::GetType(kLong));
-    attr_float_ = createCatalogAttribute(rel_numeric_, "attr_float", TypeFactory::GetType(kFloat));
-    attr_double_ = createCatalogAttribute(rel_numeric_, "attr_double", TypeFactory::GetType(kDouble));
-
-    rel_date_ = createCatalogRelation("rel_date_");
-    attr_datetime_ = createCatalogAttribute(rel_date_, "attr_datetime", TypeFactory::GetType(kDatetime));
-    attr_datetime_interval_ =
-        createCatalogAttribute(rel_date_, "attr_datetime_interval", TypeFactory::GetType(kDatetimeInterval));
-    attr_year_month_interval_ =
-        createCatalogAttribute(rel_date_, "attr_year_month_interval", TypeFactory::GetType(kYearMonthInterval));
-
-    rel_string_ = createCatalogRelation("rel_string_");
-    size_t length = 12;
-    attr_char_ = createCatalogAttribute(rel_string_, "attr_char", TypeFactory::GetType(kChar, length));
-    attr_varchar_ = createCatalogAttribute(rel_string_, "attr_varchar", TypeFactory::GetType(kVarChar, length));
-  }
-
-  void checkScalarUnaryExpressionSerialization(const UnaryOperation &operation) {
-    checkScalarSerialization(ScalarUnaryExpression(operation, createScalarInt(numeric_limits<int>::max())));
-    checkScalarSerialization(ScalarUnaryExpression(operation, createScalarLong(numeric_limits<int64_t>::max())));
-    checkScalarSerialization(ScalarUnaryExpression(operation, createScalarFloat(numeric_limits<float>::max())));
-    checkScalarSerialization(ScalarUnaryExpression(operation, createScalarDouble(numeric_limits<double>::max())));
-  }
-
-  void checkScalarBinaryExpressionSerialization(const BinaryOperation &operation) {
-    checkScalarSerialization(ScalarBinaryExpression(operation, createScalarInt(9), createScalarInt(-1)));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation, createScalarInt(0), createScalarLong(static_cast<int64_t>(9))));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation, createScalarInt(4), createScalarFloat(static_cast<float>(1.2))));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation, createScalarInt(7), createScalarDouble(static_cast<double>(3.14))));
-
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation, createScalarLong(static_cast<int64_t>(-10)), createScalarInt(8)));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation,
-                               createScalarLong(static_cast<int64_t>(9)),
-                               createScalarLong(static_cast<int64_t>(-9))));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation,
-                               createScalarLong(static_cast<int64_t>(-9)),
-                               createScalarFloat(static_cast<float>(1.2))));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation,
-                               createScalarLong(static_cast<int64_t>(9)),
-                               createScalarDouble(static_cast<double>(3.14))));
-
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation, createScalarFloat(static_cast<float>(1.2)), createScalarInt(-1)));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation,
-                               createScalarFloat(static_cast<float>(1.2)),
-                               createScalarLong(static_cast<int64_t>(-9))));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation,
-                               createScalarFloat(static_cast<float>(1.2)),
-                               createScalarFloat(static_cast<float>(-3.6))));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation,
-                               createScalarFloat(static_cast<float>(-1.2)),
-                               createScalarDouble(static_cast<double>(3.14))));
-
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation, createScalarDouble(static_cast<double>(3.14)), createScalarInt(6)));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation,
-                               createScalarDouble(static_cast<double>(3.14)),
-                               createScalarLong(static_cast<int64_t>(-9))));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation,
-                               createScalarDouble(static_cast<double>(-3.14)),
-                               createScalarFloat(static_cast<float>(1.2))));
-    checkScalarSerialization(
-        ScalarBinaryExpression(operation,
-                               createScalarDouble(static_cast<double>(3.14)),
-                               createScalarDouble(static_cast<double>(-3.14))));
-  }
-
-  CatalogRelation* createCatalogRelation(const std::string &name) {
-    return database_->getRelationByIdMutable(database_->addRelation(new CatalogRelation(NULL, name)));
-  }
-
-  const CatalogAttribute* createCatalogAttribute(CatalogRelation* rel, const std::string &name, const Type &type) {
-    rel->addAttribute(new CatalogAttribute(NULL, name, type));
-    return rel->getAttributeByName(name);
-  }
-
-  // All four pointers created below are owned by a Scalar subclass.
-  static Scalar* createScalarInt(int int_literal) {
-    return new ScalarLiteral(TypedValue(int_literal), TypeFactory::GetType(kInt));
-  }
-
-  static Scalar* createScalarLong(int64_t long_literal) {
-    return new ScalarLiteral(TypedValue(long_literal), TypeFactory::GetType(kLong));
-  }
-
-  static Scalar* createScalarFloat(float float_literal) {
-    return new ScalarLiteral(TypedValue(float_literal), TypeFactory::GetType(kFloat));
-  }
-
-  static Scalar* createScalarDouble(double double_literal) {
-    return new ScalarLiteral(TypedValue(double_literal), TypeFactory::GetType(kDouble));
-  }
-
-  void checkScalarSerialization(const Scalar &scalar) {
-    unique_ptr<Scalar> scalar_from_proto(ScalarFactory::ReconstructFromProto(scalar.getProto(), *database_));
-    compareScalar(scalar, *scalar_from_proto);
-  }
-
-  static void compareScalar(const Scalar &expected, const Scalar &checked) {
-    ASSERT_EQ(expected.getDataSource(), checked.getDataSource());
-    ASSERT_TRUE(expected.getType().equals(checked.getType()));
-
-    switch (expected.getDataSource()) {
-      case Scalar::kLiteral: {
-        compareTypedValue(expected.getType(), expected.getStaticValue(), checked.getStaticValue());
-        break;
-      }
-      case Scalar::kAttribute: {
-        compareCatalogAttribute(static_cast<const ScalarAttribute&>(expected).getAttribute(),
-                                static_cast<const ScalarAttribute&>(checked).getAttribute());
-        break;
-      }
-      case Scalar::kUnaryExpression: {
-        EXPECT_EQ(expected.hasStaticValue(), checked.hasStaticValue());
-        if (expected.hasStaticValue()) {
-          compareTypedValue(expected.getType(), expected.getStaticValue(), checked.getStaticValue());
-        }
-
-        EXPECT_EQ(static_cast<const ScalarUnaryExpression&>(expected).operation_.getUnaryOperationID(),
-                  static_cast<const ScalarUnaryExpression&>(checked).operation_.getUnaryOperationID());
-        compareScalar(*(static_cast<const ScalarUnaryExpression&>(expected).operand_),
-                      *(static_cast<const ScalarUnaryExpression&>(checked).operand_));
-        break;
-      }
-      case Scalar::kBinaryExpression: {
-        EXPECT_EQ(expected.hasStaticValue(), checked.hasStaticValue());
-        if (expected.hasStaticValue()) {
-          compareTypedValue(expected.getType(), expected.getStaticValue(), checked.getStaticValue());
-        }
-
-        EXPECT_EQ(static_cast<const ScalarBinaryExpression&>(expected).operation_.getBinaryOperationID(),
-                  static_cast<const ScalarBinaryExpression&>(checked).operation_.getBinaryOperationID());
-        compareScalar(*(static_cast<const ScalarBinaryExpression&>(expected).left_operand_),
-                      *(static_cast<const ScalarBinaryExpression&>(checked).left_operand_));
-        compareScalar(*(static_cast<const ScalarBinaryExpression&>(expected).right_operand_),
-                      *(static_cast<const ScalarBinaryExpression&>(checked).right_operand_));
-        break;
-      }
-      default:
-        FATAL_ERROR("checked is not a valid Scalar in compareScalar");
-    }
-  }
-
-  static void compareTypedValue(const Type &type,
-                                const TypedValue &expected,
-                                const TypedValue &checked) {
-    ASSERT_EQ(expected.isNull(), checked.isNull());
-
-    if (expected.isNull()) {
-      return;
-    }
-
-    switch (type.getTypeID()) {
-      case kInt:
-        EXPECT_EQ(expected.getLiteral<int>(), checked.getLiteral<int>());
-        break;
-      case kLong:
-        EXPECT_EQ(expected.getLiteral<int64_t>(), checked.getLiteral<int64_t>());
-        break;
-      case kFloat:
-        EXPECT_FLOAT_EQ(expected.getLiteral<float>(), checked.getLiteral<float>());
-        break;
-      case kDouble:
-        EXPECT_DOUBLE_EQ(expected.getLiteral<double>(), checked.getLiteral<double>());
-        break;
-      case kDatetime:
-        EXPECT_EQ(expected.getLiteral<DatetimeLit>(), checked.getLiteral<DatetimeLit>());
-        break;
-      case kDatetimeInterval:
-        EXPECT_EQ(expected.getLiteral<DatetimeIntervalLit>(), checked.getLiteral<DatetimeIntervalLit>());
-        break;
-      case kYearMonthInterval:
-        EXPECT_EQ(expected.getLiteral<YearMonthIntervalLit>(), checked.getLiteral<YearMonthIntervalLit>());
-        break;
-      case kChar:  // Fall through.
-      case kVarChar:
-        EXPECT_EQ(expected.getDataSize(), checked.getDataSize());
-        EXPECT_EQ(expected.getAsciiStringLength(), checked.getAsciiStringLength());
-        EXPECT_STREQ(static_cast<const char*>(expected.getDataPtr()),
-                     static_cast<const char*>(checked.getDataPtr()));
-        break;
-      default:
-        FATAL_ERROR("Unrecognized Type in compareTypedValue");
-    }
-  }
-
-  static void compareCatalogAttribute(const CatalogAttribute &expected, const CatalogAttribute &checked) {
-    EXPECT_EQ(expected.getID(), checked.getID());
-    EXPECT_EQ(expected.getName(), checked.getName());
-    EXPECT_TRUE(expected.getType().equals(checked.getType()));
-  }
-
-  unique_ptr<CatalogDatabase> database_;
-  // Both pointers below are owned by database_.
-  CatalogRelation *rel_numeric_, *rel_date_, *rel_string_;
-  // All pointers below are owned by relations.
-  const CatalogAttribute *attr_int_, *attr_long_, *attr_float_, *attr_double_,
-      *attr_datetime_, *attr_datetime_interval_, *attr_year_month_interval_,
-      *attr_char_, *attr_varchar_;
-};
-
-TEST_F(ScalarTest, ScalarLiteralSerializationTest) {
-  checkScalarSerialization(ScalarLiteral(TypedValue(kInt),
-                                         TypeFactory::GetType(kInt, true /* nullable */)));
-  checkScalarSerialization(ScalarLiteral(TypedValue(4),
-                                         TypeFactory::GetType(kInt, false /* nullable */)));
-
-  checkScalarSerialization(ScalarLiteral(TypedValue(kLong),
-                                         TypeFactory::GetType(kLong, true /* nullable */)));
-  checkScalarSerialization(ScalarLiteral(TypedValue(static_cast<int64_t>(9)),
-                                         TypeFactory::GetType(kLong, false /* nullable */)));
-
-  checkScalarSerialization(ScalarLiteral(TypedValue(kFloat),
-                                         TypeFactory::GetType(kFloat, true /* nullable */)));
-  checkScalarSerialization(ScalarLiteral(TypedValue(static_cast<float>(1.2)),
-                                         TypeFactory::GetType(kFloat, false /* nullable */)));
-
-  checkScalarSerialization(ScalarLiteral(TypedValue(kDouble),
-                                         TypeFactory::GetType(kDouble, true /* nullable */)));
-  checkScalarSerialization(ScalarLiteral(TypedValue(static_cast<double>(1.3)),
-                                         TypeFactory::GetType(kDouble, false /* nullable */)));
-
-  checkScalarSerialization(ScalarLiteral(TypedValue(kChar),
-                                         TypeFactory::GetType(kChar, 0, true /* nullable */)));
-  checkScalarSerialization(ScalarLiteral(TypedValue(kChar, kSampleStringShort, strlen(kSampleStringShort)+5),
-                                         TypeFactory::GetType(kChar,
-                                                              strlen(kSampleStringShort) + 5,
-                                                              false /* nullable */)));
-
-  checkScalarSerialization(ScalarLiteral(TypedValue(kVarChar),
-                                         TypeFactory::GetType(kVarChar, 0, true)));
-  checkScalarSerialization(ScalarLiteral(TypedValue(kVarChar, kSampleStringLong, strlen(kSampleStringLong)+1),
-                                         TypeFactory::GetType(kVarChar,
-                                                              strlen(kSampleStringLong),
-                                                              false /* nullable */)));
-
-  checkScalarSerialization(ScalarLiteral(TypedValue(kDatetime),
-                                         TypeFactory::GetType(kDatetime, true /* nullable */)));
-  DatetimeLit datetime;
-  datetime.ticks = static_cast<int64_t>(0xFFFFF);
-  checkScalarSerialization(ScalarLiteral(TypedValue(datetime),
-                                         TypeFactory::GetType(kDatetime, false /* nullable */)));
-
-  checkScalarSerialization(ScalarLiteral(TypedValue(kDatetimeInterval),
-                                         TypeFactory::GetType(kDatetimeInterval,
-                                                              true /* nullable */)));
-  DatetimeIntervalLit datetime_interval;
-  datetime_interval.interval_ticks = static_cast<int64_t>(0xFF);
-  checkScalarSerialization(ScalarLiteral(TypedValue(datetime_interval),
-                                         TypeFactory::GetType(kDatetimeInterval,
-                                                              false /* nullable */)));
-
-  checkScalarSerialization(ScalarLiteral(TypedValue(kYearMonthInterval),
-                                         TypeFactory::GetType(kYearMonthInterval,
-                                                              true /* nullable */)));
-  YearMonthIntervalLit year_month_interval;
-  year_month_interval.months = static_cast<int64_t>(14);
-  checkScalarSerialization(ScalarLiteral(TypedValue(year_month_interval),
-                                         TypeFactory::GetType(kYearMonthInterval,
-                                                              false /* nullable */)));
-}
-
-TEST_F(ScalarTest, ScalarAttributeSerializationTest) {
-  checkScalarSerialization(ScalarAttribute(*attr_int_));
-  checkScalarSerialization(ScalarAttribute(*attr_long_));
-  checkScalarSerialization(ScalarAttribute(*attr_float_));
-  checkScalarSerialization(ScalarAttribute(*attr_double_));
-
-  checkScalarSerialization(ScalarAttribute(*attr_datetime_));
-  checkScalarSerialization(ScalarAttribute(*attr_datetime_interval_));
-  checkScalarSerialization(ScalarAttribute(*attr_year_month_interval_));
-
-  checkScalarSerialization(ScalarAttribute(*attr_char_));
-  checkScalarSerialization(ScalarAttribute(*attr_varchar_));
-}
-
-TEST_F(ScalarTest, ScalarUnaryExpressionSerializationTest) {
-  checkScalarUnaryExpressionSerialization(UnaryOperationFactory::GetUnaryOperation(UnaryOperationID::kNegate));
-  checkScalarUnaryExpressionSerialization(NumericCastOperation::Instance(TypeFactory::GetType(kDouble)));
-}
-
-TEST_F(ScalarTest, ScalarBinaryExpressionSerializationTest) {
-  checkScalarBinaryExpressionSerialization(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd));
-  checkScalarBinaryExpressionSerialization(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kSubtract));
-  checkScalarBinaryExpressionSerialization(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kMultiply));
-  checkScalarBinaryExpressionSerialization(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide));
-  checkScalarBinaryExpressionSerialization(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kModulo));
-}
-
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/table_generator/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/expressions/table_generator/CMakeLists.txt b/expressions/table_generator/CMakeLists.txt
deleted file mode 100644
index 037944e..0000000
--- a/expressions/table_generator/CMakeLists.txt
+++ /dev/null
@@ -1,66 +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.
-
-QS_PROTOBUF_GENERATE_CPP(expressions_tablegenerator_GeneratorFunction_proto_srcs
-                         expressions_tablegenerator_GeneratorFunction_proto_hdrs
-                         GeneratorFunction.proto)
-
-# Declare micro-libs:
-add_library(quickstep_expressions_tablegenerator_GenerateSeries
-            ../../empty_src.cpp
-            GeneratorFunction.hpp)
-add_library(quickstep_expressions_tablegenerator_GenerateSeriesHandle
-            ../../empty_src.cpp
-            GeneratorFunctionHandle.hpp)
-add_library(quickstep_expressions_tablegenerator_GeneratorFunction
-            ../../empty_src.cpp
-            GeneratorFunction.hpp)
-add_library(quickstep_expressions_tablegenerator_GeneratorFunction_proto
-            ${expressions_tablegenerator_GeneratorFunction_proto_srcs})
-add_library(quickstep_expressions_tablegenerator_GeneratorFunctionFactory
-            GeneratorFunctionFactory.cpp
-            GeneratorFunctionFactory.hpp)
-add_library(quickstep_expressions_tablegenerator_GeneratorFunctionHandle
-            ../../empty_src.cpp
-            GeneratorFunctionHandle.hpp)
-
-# Link dependencies:
-target_link_libraries(quickstep_expressions_tablegenerator_GenerateSeries
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_tablegenerator_GenerateSeriesHandle
-                      glog
-                      quickstep_expressions_tablegenerator_GeneratorFunction_proto
-                      quickstep_types_TypedValue
-                      quickstep_types_TypedValue_proto
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_tablegenerator_GeneratorFunction
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_tablegenerator_GeneratorFunctionFactory
-                      glog
-                      quickstep_expressions_tablegenerator_GenerateSeries
-                      quickstep_expressions_tablegenerator_GeneratorFunction
-                      quickstep_expressions_tablegenerator_GeneratorFunction_proto
-                      quickstep_types_TypedValue
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_tablegenerator_GeneratorFunctionHandle
-                      quickstep_expressions_tablegenerator_GeneratorFunction_proto
-                      quickstep_types_TypedValue
-                      quickstep_types_TypedValue_proto
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_tablegenerator_GeneratorFunction_proto
-                      quickstep_types_TypedValue_proto
-                      ${PROTOBUF_LIBRARY})


Mime
View raw message