You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by sh...@apache.org on 2016/07/14 16:28:08 UTC
incubator-quickstep git commit: Added unittest for avg on Cumulative
aggregation and sliding window
Repository: incubator-quickstep
Updated Branches:
refs/heads/SQL-window-aggregation 0f5c41d15 -> 5f4647b73
Added unittest for avg on Cumulative aggregation and sliding window
Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/5f4647b7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/5f4647b7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/5f4647b7
Branch: refs/heads/SQL-window-aggregation
Commit: 5f4647b73a57981838540185bf0bc63e80a3c1dd
Parents: 0f5c41d
Author: shixuan-fan <sh...@apache.org>
Authored: Thu Jul 14 16:29:08 2016 +0000
Committer: shixuan-fan <sh...@apache.org>
Committed: Thu Jul 14 16:29:08 2016 +0000
----------------------------------------------------------------------
expressions/window_aggregation/CMakeLists.txt | 34 +++
.../WindowAggregateFunction.hpp | 1 -
.../WindowAggregateFunctionAvg.cpp | 4 +-
.../WindowAggregateFunctionAvg.hpp | 1 -
.../WindowAggregationHandle.hpp | 5 +-
.../WindowAggregationHandleAvg.cpp | 3 +-
.../WindowAggregationHandleAvg.hpp | 3 +-
.../WindowAggregationHandleAvg_unittest.cpp | 235 ++++++++++++++++---
storage/WindowAggregationOperationState.cpp | 20 +-
9 files changed, 243 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5f4647b7/expressions/window_aggregation/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/CMakeLists.txt b/expressions/window_aggregation/CMakeLists.txt
index 4ff2dae..db11ddd 100644
--- a/expressions/window_aggregation/CMakeLists.txt
+++ b/expressions/window_aggregation/CMakeLists.txt
@@ -100,3 +100,37 @@ target_link_libraries(quickstep_expressions_windowaggregation_WindowAggregationH
quickstep_types_operations_binaryoperations_BinaryOperationID
quickstep_types_operations_comparisons_Comparison
quickstep_utility_Macros)
+
+# Tests:
+
+# Unified executable to ammortize cost of linking.
+add_executable(WindowAggregationHandle_tests
+ "${CMAKE_CURRENT_SOURCE_DIR}/tests/WindowAggregationHandleAvg_unittest.cpp")
+target_link_libraries(WindowAggregationHandle_tests
+ gtest
+ gtest_main
+ quickstep_catalog_CatalogTypedefs
+ quickstep_expressions_windowaggregation_WindowAggregateFunction
+ quickstep_expressions_windowaggregation_WindowAggregateFunctionFactory
+ quickstep_expressions_windowaggregation_WindowAggregationHandle
+ quickstep_expressions_windowaggregation_WindowAggregationHandleAvg
+ quickstep_expressions_windowaggregation_WindowAggregationID
+ quickstep_storage_ValueAccessor
+ quickstep_types_CharType
+ quickstep_types_DateOperatorOverloads
+ quickstep_types_DatetimeIntervalType
+ quickstep_types_DatetimeType
+ quickstep_types_DoubleType
+ quickstep_types_FloatType
+ quickstep_types_IntType
+ quickstep_types_IntervalLit
+ quickstep_types_LongType
+ quickstep_types_Type
+ quickstep_types_TypeFactory
+ quickstep_types_TypeID
+ quickstep_types_TypedValue
+ quickstep_types_VarCharType
+ quickstep_types_YearMonthIntervalType
+ quickstep_types_containers_ColumnVector
+ quickstep_types_containers_ColumnVectorsValueAccessor)
+add_test(WindowAggregationHandle_tests WindowAggregationHandle_tests)
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5f4647b7/expressions/window_aggregation/WindowAggregateFunction.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunction.hpp b/expressions/window_aggregation/WindowAggregateFunction.hpp
index 863ac57..eb82943 100644
--- a/expressions/window_aggregation/WindowAggregateFunction.hpp
+++ b/expressions/window_aggregation/WindowAggregateFunction.hpp
@@ -130,7 +130,6 @@ class WindowAggregateFunction {
* is responsible for deleting the returned object.
**/
virtual WindowAggregationHandle* createHandle(
- const CatalogRelationSchema &relation,
std::vector<const Type*> &&argument_types,
std::vector<const Type*> &&partition_key_types) const = 0;
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5f4647b7/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp b/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
index ce0b566..812d8de 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
@@ -72,15 +72,13 @@ const Type* WindowAggregateFunctionAvg::resultTypeForArgumentTypes(
}
WindowAggregationHandle* WindowAggregateFunctionAvg::createHandle(
- const CatalogRelationSchema &relation,
std::vector<const Type*> &&argument_types,
std::vector<const Type*> &&partition_key_types) const {
DCHECK(canApplyToTypes(argument_types))
<< "Attempted to create an WindowAggregationHandleAvg for argument Type(s)"
<< " that AVG can not be applied to.";
- return new WindowAggregationHandleAvg(relation,
- std::move(partition_key_types),
+ return new WindowAggregationHandleAvg(std::move(partition_key_types),
*argument_types.front());
}
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5f4647b7/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp b/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp
index 07d6b4f..18e1022 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp
@@ -57,7 +57,6 @@ class WindowAggregateFunctionAvg : public WindowAggregateFunction {
const std::vector<const Type*> &argument_types) const override;
WindowAggregationHandle* createHandle(
- const CatalogRelationSchema &relation,
std::vector<const Type*> &&argument_types,
std::vector<const Type*> &&partition_key_types) const override;
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5f4647b7/expressions/window_aggregation/WindowAggregationHandle.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandle.hpp b/expressions/window_aggregation/WindowAggregationHandle.hpp
index 831bcbf..8941209 100644
--- a/expressions/window_aggregation/WindowAggregationHandle.hpp
+++ b/expressions/window_aggregation/WindowAggregationHandle.hpp
@@ -120,9 +120,7 @@ class WindowAggregationHandle {
* @param num_following The number of rows/range that follows the current row.
* @param storage_manager A pointer to the storage manager.
**/
- WindowAggregationHandle(const CatalogRelationSchema &relation,
- std::vector<const Type*> &&partition_key_types)
- : relation_(relation) {
+ WindowAggregationHandle(std::vector<const Type*> &&partition_key_types) {
// Comparison operators for checking if two tuples belong to the same partition.
for (const Type *partition_key_type : partition_key_types) {
equal_comparators_.emplace_back(
@@ -131,7 +129,6 @@ class WindowAggregationHandle {
}
}
- const CatalogRelationSchema &relation_;
std::vector<std::unique_ptr<UncheckedComparator>> equal_comparators_;
private:
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5f4647b7/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandleAvg.cpp b/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
index 14fc1d9..18ab52f 100644
--- a/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
+++ b/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
@@ -46,10 +46,9 @@ namespace quickstep {
class StorageManager;
WindowAggregationHandleAvg::WindowAggregationHandleAvg(
- const CatalogRelationSchema &relation,
std::vector<const Type*> &&partition_key_types,
const Type &type)
- : WindowAggregationHandle(relation, std::move(partition_key_types)),
+ : WindowAggregationHandle(std::move(partition_key_types)),
argument_type_(type) {
// We sum Int as Long and Float as Double so that we have more headroom when
// adding many values.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5f4647b7/expressions/window_aggregation/WindowAggregationHandleAvg.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandleAvg.hpp b/expressions/window_aggregation/WindowAggregationHandleAvg.hpp
index 72076fa..18b801e 100644
--- a/expressions/window_aggregation/WindowAggregationHandleAvg.hpp
+++ b/expressions/window_aggregation/WindowAggregationHandleAvg.hpp
@@ -76,8 +76,7 @@ class WindowAggregationHandleAvg : public WindowAggregationHandle {
* @param storage_manager A pointer to the storage manager.
* @param type Type of the avg value.
**/
- explicit WindowAggregationHandleAvg(const CatalogRelationSchema &relation,
- std::vector<const Type*> &&partition_key_types,
+ explicit WindowAggregationHandleAvg(std::vector<const Type*> &&partition_key_types,
const Type &type);
TypedValue calculateOneWindow(
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5f4647b7/expressions/window_aggregation/tests/WindowAggregationHandleAvg_unittest.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/tests/WindowAggregationHandleAvg_unittest.cpp b/expressions/window_aggregation/tests/WindowAggregationHandleAvg_unittest.cpp
index 58c8019..9d3d2d8 100644
--- a/expressions/window_aggregation/tests/WindowAggregationHandleAvg_unittest.cpp
+++ b/expressions/window_aggregation/tests/WindowAggregationHandleAvg_unittest.cpp
@@ -28,6 +28,7 @@
#include "expressions/window_aggregation/WindowAggregationHandle.hpp"
#include "expressions/window_aggregation/WindowAggregationHandleAvg.hpp"
#include "expressions/window_aggregation/WindowAggregationID.hpp"
+#include "storage/ValueAccessor.hpp"
#include "types/CharType.hpp"
#include "types/DateOperatorOverloads.hpp"
#include "types/DatetimeIntervalType.hpp"
@@ -43,6 +44,7 @@
#include "types/VarCharType.hpp"
#include "types/YearMonthIntervalType.hpp"
#include "types/containers/ColumnVector.hpp"
+#include "types/containers/ColumnVectorsValueAccessor.hpp"
#include "gtest/gtest.h"
@@ -53,6 +55,8 @@ namespace {
constexpr int kNumTuples = 100;
constexpr int kNumTuplesPerPartition = 8;
constexpr int kNullInterval = 25;
+ constexpr int kNumPreceding = 2;
+ constexpr int kNumFollowing = 2;
} // namespace
@@ -60,13 +64,12 @@ namespace {
class WindowAggregationHandleAvgTest : public::testing::TestWithParam<bool> {
protected:
// Handle initialization.
- void initializeHandle(const Type &argument_type,
- const std::vector<const Type*> &partition_key_types) {
- WindowAggregateFunction *function =
- WindowAggregateFactory::Get(WindowAggregationID::kAvg);
- handle_avg_.reset(function->createHandle(relation_,
- std::vector<const Type*>(1, &argument_type),
- partition_key_types));
+ void initializeHandle(const Type &argument_type) {
+ const WindowAggregateFunction &function =
+ WindowAggregateFunctionFactory::Get(WindowAggregationID::kAvg);
+ std::vector<const Type*> partition_key_types(1, &TypeFactory::GetType(kInt, false));
+ handle_avg_.reset(function.createHandle(std::vector<const Type*>(1, &argument_type),
+ std::move(partition_key_types)));
}
// Test canApplyToTypes().
@@ -90,39 +93,37 @@ class WindowAggregationHandleAvgTest : public::testing::TestWithParam<bool> {
template <typename CppType>
static void CheckAvgValues(
- std::vector<CppType*> expected,
+ const std::vector<CppType*> &expected,
const ColumnVector *actual) {
EXPECT_TRUE(actual->isNative());
- NativeColumnVector *native = static_cast<const NativeColumnVector*>(actual);
+ const NativeColumnVector *native = static_cast<const NativeColumnVector*>(actual);
- EXPECT_EQ(expected.size(), actual->size());
+ EXPECT_EQ(expected.size(), native->size());
for (std::size_t i = 0; i < expected.size(); ++i) {
if (expected[i] == nullptr) {
- EXPECT_TRUE(actual->getTypedValue(i).isNull());
+ EXPECT_TRUE(native->getTypedValue(i).isNull());
} else {
- EXPECT_EQ(expected[i], actual->getTypedValue(i).getLiteral<CppType>());
+ EXPECT_EQ(*expected[i], native->getTypedValue(i).getLiteral<CppType>());
}
}
}
- // Static templated method for set a meaningful value to data types.
+ // Static templated methods for set a meaningful value to data types.
template <typename CppType>
static void SetDataType(int value, CppType *data) {
*data = value;
}
template <typename GenericType, typename OutputType = DoubleType>
- void checkAggregationAvgGeneric() {
+ void checkWindowAggregationAvgGeneric() {
const GenericType &type = GenericType::Instance(true);
initializeHandle(type);
- EXPECT_EQ(0, aggregation_handle_avg_->finalize()->getNumTuplesVirtual());
// Create argument, partition key and cpptype vectors.
- std::vector<GenericType::cpptype*> argument_cpp_vector;
+ std::vector<typename GenericType::cpptype*> argument_cpp_vector;
argument_cpp_vector.reserve(kNumTuples);
ColumnVector *argument_type_vector =
createArgumentGeneric<GenericType>(&argument_cpp_vector);
- const IntType &int_type = ;
NativeColumnVector *partition_key_vector =
new NativeColumnVector(IntType::InstanceNonNullable(), kNumTuples + 2);
@@ -130,25 +131,28 @@ class WindowAggregationHandleAvgTest : public::testing::TestWithParam<bool> {
partition_key_vector->appendTypedValue(TypedValue(i / kNumTuplesPerPartition));
}
- // Create tuple ValueAccessor
+ // Create tuple ValueAccessor.
ColumnVectorsValueAccessor *tuple_accessor = new ColumnVectorsValueAccessor();
tuple_accessor->addColumn(partition_key_vector);
tuple_accessor->addColumn(argument_type_vector);
// Test UNBOUNDED PRECEDING AND CURRENT ROW.
- calculateAccumulative<GenericType, OutputType>(tuple_accessor,
- argument_type_vector,
- argument_cpp_vector);
+ checkAccumulate<GenericType, OutputType>(tuple_accessor,
+ argument_type_vector,
+ argument_cpp_vector);
+ // Test kNumPreceding PRECEDING AND kNumFollowing FOLLOWING.
+ checkSlidingWindow<GenericType, OutputType>(tuple_accessor,
+ argument_type_vector,
+ argument_cpp_vector);
}
template <typename GenericType>
ColumnVector *createArgumentGeneric(
- std::vector<GenericType::cpptype*> *argument_cpp_vector) {
+ std::vector<typename GenericType::cpptype*> *argument_cpp_vector) {
const GenericType &type = GenericType::Instance(true);
- NativeColumnVector *column = new NativeColumnVector(type, kNumSamples);
+ NativeColumnVector *column = new NativeColumnVector(type, kNumTuples);
- column->appendTypedValue(type.makeNullValue());
- for (int i = 0; i < kNumSamples; ++i) {
+ for (int i = 0; i < kNumTuples; ++i) {
// Insert a NULL every kNullInterval tuples.
if (i % kNullInterval == 0) {
argument_cpp_vector->push_back(nullptr);
@@ -156,7 +160,7 @@ class WindowAggregationHandleAvgTest : public::testing::TestWithParam<bool> {
continue;
}
- typename GenericType::cpptype val = new GenericType::cpptype;
+ typename GenericType::cpptype *val = new typename GenericType::cpptype;
if (type.getTypeID() == kInt || type.getTypeID() == kLong) {
SetDataType(i - 10, val);
@@ -172,9 +176,9 @@ class WindowAggregationHandleAvgTest : public::testing::TestWithParam<bool> {
}
template <typename GenericType, typename OutputType>
- void calculateAccumulate(ValueAccessor *tuple_accessor,
- ColumnVector *argument_type_vector,
- const std::vector<GenericType::cpptype> &argument_cpp_vector) {
+ void checkAccumulate(ColumnVectorsValueAccessor *tuple_accessor,
+ ColumnVector *argument_type_vector,
+ const std::vector<typename GenericType::cpptype*> &argument_cpp_vector) {
std::vector<ColumnVector*> arguments;
arguments.push_back(argument_type_vector);
// The partition key index is 0.
@@ -189,7 +193,7 @@ class WindowAggregationHandleAvgTest : public::testing::TestWithParam<bool> {
0 /* num_following: CURRENT ROW */);
// Get the cpptype result.
- std::vector<OutputType::cpptype*> result_cpp_vector;
+ std::vector<typename OutputType::cpptype*> result_cpp_vector;
bool is_null;
typename GenericType::cpptype sum;
int count;
@@ -211,7 +215,88 @@ class WindowAggregationHandleAvgTest : public::testing::TestWithParam<bool> {
} else {
sum += *value;
count++;
- result_cpp_vector.push_back(static_cast<typename OutputType>(sum) / count);
+ typename OutputType::cpptype *result_cpp_value =
+ new typename OutputType::cpptype;
+ *result_cpp_value = static_cast<typename OutputType::cpptype>(sum) / count;
+ result_cpp_vector.push_back(result_cpp_value);
+ }
+ }
+
+ CheckAvgValues(result_cpp_vector, result);
+ }
+
+ template <typename GenericType, typename OutputType>
+ void checkSlidingWindow(ColumnVectorsValueAccessor *tuple_accessor,
+ ColumnVector *argument_type_vector,
+ const std::vector<typename GenericType::cpptype*> &argument_cpp_vector) {
+ std::vector<ColumnVector*> arguments;
+ arguments.push_back(argument_type_vector);
+ // The partition key index is 0.
+ std::vector<attribute_id> partition_key(1, 0);
+
+ ColumnVector *result =
+ handle_avg_->calculate(tuple_accessor,
+ std::move(arguments),
+ partition_key,
+ true /* is_row */,
+ kNumPreceding,
+ kNumFollowing);
+
+ // Get the cpptype result.
+ // For each value, calculate all surrounding values in the window.
+ std::vector<typename OutputType::cpptype*> result_cpp_vector;
+
+ for (std::size_t i = 0; i < argument_cpp_vector.size(); ++i) {
+ if (argument_cpp_vector[i] == nullptr) {
+ result_cpp_vector.push_back(nullptr);
+ continue;
+ }
+
+ typename GenericType::cpptype sum;
+ SetDataType(0, &sum);
+ sum += *argument_cpp_vector[i];
+ int count = 1;
+ bool is_null = false;
+
+ for (int precede = 1; precede <= kNumPreceding; ++precede) {
+ // Not the same partition.
+ if (i / kNumTuplesPerPartition != (i - precede) / kNumTuplesPerPartition
+ || i - precede < 0) {
+ break;
+ }
+
+ if (argument_cpp_vector[i - precede] == nullptr) {
+ is_null = true;
+ break;
+ }
+
+ sum += *argument_cpp_vector[i - precede];
+ count++;
+ }
+
+ for (int follow = 1; follow <= kNumPreceding; ++follow) {
+ // Not the same partition.
+ if (i / kNumTuplesPerPartition != (i + follow) / kNumTuplesPerPartition
+ || i + follow >= kNumTuples) {
+ break;
+ }
+
+ if (argument_cpp_vector[i + follow] == nullptr) {
+ is_null = true;
+ break;
+ }
+
+ sum += *argument_cpp_vector[i + follow];
+ count++;
+ }
+
+ if (is_null) {
+ result_cpp_vector.push_back(nullptr);
+ } else {
+ typename OutputType::cpptype *result_cpp_value =
+ new typename OutputType::cpptype;
+ *result_cpp_value = static_cast<typename OutputType::cpptype>(sum) / count;
+ result_cpp_vector.push_back(result_cpp_value);
}
}
@@ -221,4 +306,92 @@ class WindowAggregationHandleAvgTest : public::testing::TestWithParam<bool> {
std::unique_ptr<WindowAggregationHandle> handle_avg_;
};
+template <>
+void WindowAggregationHandleAvgTest::CheckAvgValues<double>(
+ const std::vector<double*> &expected,
+ const ColumnVector *actual) {
+ EXPECT_TRUE(actual->isNative());
+ const NativeColumnVector *native = static_cast<const NativeColumnVector*>(actual);
+
+ EXPECT_EQ(expected.size(), native->size());
+ for (std::size_t i = 0; i < expected.size(); ++i) {
+ if (expected[i] == nullptr) {
+ EXPECT_TRUE(native->getTypedValue(i).isNull());
+ } else {
+ EXPECT_EQ(*expected[i], native->getTypedValue(i).getLiteral<double>());
+ }
+ }
+}
+
+template <>
+void WindowAggregationHandleAvgTest::SetDataType<DatetimeIntervalLit>(
+ int value, DatetimeIntervalLit *data) {
+ data->interval_ticks = value;
+}
+
+template <>
+void WindowAggregationHandleAvgTest::SetDataType<YearMonthIntervalLit>(
+ int value, YearMonthIntervalLit *data) {
+ data->months = value;
+}
+
+typedef WindowAggregationHandleAvgTest WindowAggregationHandleAvgDeathTest;
+
+TEST_F(WindowAggregationHandleAvgTest, IntTypeTest) {
+ checkWindowAggregationAvgGeneric<IntType>();
+}
+
+TEST_F(WindowAggregationHandleAvgTest, LongTypeTest) {
+ checkWindowAggregationAvgGeneric<LongType>();
+}
+
+TEST_F(WindowAggregationHandleAvgTest, FloatTypeTest) {
+ checkWindowAggregationAvgGeneric<FloatType>();
+}
+
+TEST_F(WindowAggregationHandleAvgTest, DoubleTypeTest) {
+ checkWindowAggregationAvgGeneric<DoubleType>();
+}
+
+TEST_F(WindowAggregationHandleAvgTest, DatetimeIntervalTypeTest) {
+ checkWindowAggregationAvgGeneric<DatetimeIntervalType, DatetimeIntervalType>();
+}
+
+TEST_F(WindowAggregationHandleAvgTest, YearMonthIntervalTypeTest) {
+ checkWindowAggregationAvgGeneric<YearMonthIntervalType, YearMonthIntervalType>();
+}
+
+#ifdef QUICKSTEP_DEBUG
+TEST_F(WindowAggregationHandleAvgDeathTest, CharTypeTest) {
+ const Type &type = CharType::Instance(true, 10);
+ EXPECT_DEATH(initializeHandle(type), "");
+}
+
+TEST_F(WindowAggregationHandleAvgDeathTest, VarTypeTest) {
+ const Type &type = VarCharType::Instance(true, 10);
+ EXPECT_DEATH(initializeHandle(type), "");
+}
+#endif
+
+TEST_F(WindowAggregationHandleAvgDeathTest, canApplyToTypeTest) {
+ EXPECT_TRUE(CanApplyToTypesTest(kInt));
+ EXPECT_TRUE(CanApplyToTypesTest(kLong));
+ EXPECT_TRUE(CanApplyToTypesTest(kFloat));
+ EXPECT_TRUE(CanApplyToTypesTest(kDouble));
+ EXPECT_FALSE(CanApplyToTypesTest(kChar));
+ EXPECT_FALSE(CanApplyToTypesTest(kVarChar));
+ EXPECT_FALSE(CanApplyToTypesTest(kDatetime));
+ EXPECT_TRUE(CanApplyToTypesTest(kDatetimeInterval));
+ EXPECT_TRUE(CanApplyToTypesTest(kYearMonthInterval));
+}
+
+TEST_F(WindowAggregationHandleAvgDeathTest, ResultTypeForArgumentTypeTest) {
+ EXPECT_TRUE(ResultTypeForArgumentTypesTest(kInt, kDouble));
+ EXPECT_TRUE(ResultTypeForArgumentTypesTest(kLong, kDouble));
+ EXPECT_TRUE(ResultTypeForArgumentTypesTest(kFloat, kDouble));
+ EXPECT_TRUE(ResultTypeForArgumentTypesTest(kDouble, kDouble));
+ EXPECT_TRUE(ResultTypeForArgumentTypesTest(kDatetimeInterval, kDatetimeInterval));
+ EXPECT_TRUE(ResultTypeForArgumentTypesTest(kYearMonthInterval, kYearMonthInterval));
+}
+
} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5f4647b7/storage/WindowAggregationOperationState.cpp
----------------------------------------------------------------------
diff --git a/storage/WindowAggregationOperationState.cpp b/storage/WindowAggregationOperationState.cpp
index ea522b8..668af9b 100644
--- a/storage/WindowAggregationOperationState.cpp
+++ b/storage/WindowAggregationOperationState.cpp
@@ -87,26 +87,8 @@ WindowAggregationOperationState::WindowAggregationOperationState(
// Create the handle and initial state.
window_aggregation_handle_.reset(
- window_aggregate_function->createHandle(input_relation_,
- std::move(argument_types),
+ window_aggregate_function->createHandle(std::move(argument_types),
std::move(partition_by_types)));
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
- // See if all of this window aggregate's arguments are attributes in the input
- // relation. If so, remember the attribute IDs so that we can do copy elision
- // when actually performing the window aggregation.
- arguments_as_attributes_.reserve(arguments_.size());
- for (const std::unique_ptr<const Scalar> &argument : arguments_) {
- const attribute_id argument_id = argument->getAttributeIdForValueAccessor();
- if (argument_id == -1) {
- arguments_as_attributes_.clear();
- break;
- } else {
- DCHECK_EQ(input_relation.getID(), argument->getRelationIdForValueAccessor());
- arguments_as_attributes_.push_back(argument_id);
- }
- }
-#endif
}
WindowAggregationOperationState* WindowAggregationOperationState::ReconstructFromProto(