patch 4.0
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
function(aggr_unittest case)
|
||||
ob_unittest(${ARGV})
|
||||
target_sources(${case} PRIVATE ../table/ob_fake_table.h ../set/ob_set_test_util.h)
|
||||
endfunction()
|
||||
aggr_unittest(test_hash_distinct)
|
||||
aggr_unittest(test_hash_groupby)
|
||||
aggr_unittest(test_merge_groupby)
|
||||
aggr_unittest(test_scalar_aggregate)
|
||||
aggr_unittest(test_merge_distinct)
|
||||
#function(aggr_unittest case)
|
||||
# ob_unittest(${ARGV})
|
||||
# target_sources(${case} PRIVATE ../table/ob_fake_table.h ../set/ob_set_test_util.h)
|
||||
#endfunction()
|
||||
#aggr_unittest(test_hash_distinct)
|
||||
#aggr_unittest(test_hash_groupby)
|
||||
#aggr_unittest(test_merge_groupby)
|
||||
#aggr_unittest(test_scalar_aggregate)
|
||||
#aggr_unittest(test_merge_distinct)
|
||||
|
@ -25,24 +25,27 @@
|
||||
#include "sql/engine/aggregate/ob_groupby.h"
|
||||
#include "sql/engine/aggregate/ob_scalar_aggregate.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "share/ob_worker.h"
|
||||
#include "lib/worker.h"
|
||||
#include "observer/omt/ob_tenant_config_mgr.h"
|
||||
#include "observer/ob_server.h"
|
||||
|
||||
using namespace oceanbase::share;
|
||||
using namespace oceanbase::omt;
|
||||
class TestAggregateFactory {
|
||||
class TestAggregateFactory
|
||||
{
|
||||
public:
|
||||
TestAggregateFactory()
|
||||
{}
|
||||
~TestAggregateFactory()
|
||||
{}
|
||||
TestAggregateFactory() {}
|
||||
~TestAggregateFactory() {}
|
||||
|
||||
static void init(ObExecContext& ctx, ObGroupBy& groupby_op, int64_t col_count, bool is_distinct,
|
||||
bool is_number = true, ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN,
|
||||
ObCollationType group_cs_type = CS_TYPE_UTF8MB4_BIN)
|
||||
static void init(ObExecContext &ctx,
|
||||
ObGroupBy &groupby_op,
|
||||
int64_t col_count,
|
||||
bool is_distinct,
|
||||
bool is_number = true,
|
||||
ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN,
|
||||
ObCollationType group_cs_type = CS_TYPE_UTF8MB4_BIN)
|
||||
{
|
||||
ObPhysicalPlanCtx* plan_ctx = NULL;
|
||||
ObPhysicalPlanCtx *plan_ctx = NULL;
|
||||
groupby_op.reset();
|
||||
groupby_op.reuse();
|
||||
fake_table_.reset();
|
||||
@ -56,10 +59,11 @@ public:
|
||||
ASSERT_EQ(OB_SUCCESS, my_session_.init_tenant(ObString::make_string("sys"), 1));
|
||||
ASSERT_EQ(OB_SUCCESS, ObPreProcessSysVars::init_sys_var());
|
||||
ASSERT_EQ(OB_SUCCESS, my_session_.load_default_sys_variable(false, true));
|
||||
ASSERT_EQ(OB_SUCCESS, my_session_.load_default_configs_in_pc());
|
||||
|
||||
THIS_WORKER.set_timeout_ts(ObTimeUtility::current_time() + 6000000000);
|
||||
fake_table_.set_column_count(col_count);
|
||||
result_table_.set_column_count(col_count + (is_number ? 5 : 3) + (is_distinct ? 1 : 0)); // sum, avg
|
||||
result_table_.set_column_count(col_count + (is_number ? 5 : 3) + (is_distinct ? 1 : 0)); // sum, avg
|
||||
groupby_op.set_column_count(col_count + (is_number ? 5 : 3) + (is_distinct ? 1 : 0));
|
||||
|
||||
fake_table_.set_id(0);
|
||||
@ -82,10 +86,14 @@ public:
|
||||
groupby_op.add_group_column_idx(2, group_cs_type);
|
||||
}
|
||||
|
||||
static void init(ObExecContext& ctx, ObScalarAggregate& scalar_aggr_op, int64_t col_count, bool is_distinct,
|
||||
bool is_number = true, ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN)
|
||||
static void init(ObExecContext &ctx,
|
||||
ObScalarAggregate &scalar_aggr_op,
|
||||
int64_t col_count,
|
||||
bool is_distinct,
|
||||
bool is_number = true,
|
||||
ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN)
|
||||
{
|
||||
ObPhysicalPlanCtx* plan_ctx = NULL;
|
||||
ObPhysicalPlanCtx *plan_ctx = NULL;
|
||||
|
||||
scalar_aggr_op.reset();
|
||||
scalar_aggr_op.reuse();
|
||||
@ -100,9 +108,10 @@ public:
|
||||
ASSERT_EQ(OB_SUCCESS, my_session_.init_tenant(ObString::make_string("sys"), 1));
|
||||
ASSERT_EQ(OB_SUCCESS, ObPreProcessSysVars::init_sys_var());
|
||||
ASSERT_EQ(OB_SUCCESS, my_session_.load_default_sys_variable(false, true));
|
||||
ASSERT_EQ(OB_SUCCESS, my_session_.load_default_configs_in_pc());
|
||||
|
||||
fake_table_.set_column_count(col_count);
|
||||
result_table_.set_column_count(col_count + (is_number ? 5 : 3) + (is_distinct ? 1 : 0)); // sum, avg
|
||||
result_table_.set_column_count(col_count + (is_number ? 5 : 3) + (is_distinct ? 1 : 0)); // sum, avg
|
||||
scalar_aggr_op.set_column_count(col_count + (is_number ? 5 : 3) + (is_distinct ? 1 : 0));
|
||||
scalar_aggr_op.init(10);
|
||||
fake_table_.set_id(0);
|
||||
@ -115,8 +124,8 @@ public:
|
||||
|
||||
scalar_aggr_op.set_child(0, fake_table_);
|
||||
|
||||
ASSERT_EQ(OB_SUCCESS, ctx.init_phy_op(3));
|
||||
ctx.set_my_session(&my_session_);
|
||||
ASSERT_EQ(OB_SUCCESS, ctx.init_phy_op(3));
|
||||
ASSERT_EQ(OB_SUCCESS, ctx.create_physical_plan_ctx());
|
||||
plan_ctx = ctx.get_physical_plan_ctx();
|
||||
ASSERT_FALSE(NULL == plan_ctx);
|
||||
@ -124,9 +133,9 @@ public:
|
||||
add_aggr_column(scalar_aggr_op, is_distinct, is_number, agg_cs_type);
|
||||
}
|
||||
|
||||
static void init(ObExecContext& ctx, ObScalarAggregate& scalar_aggr_op, int64_t col_count)
|
||||
static void init(ObExecContext &ctx, ObScalarAggregate &scalar_aggr_op, int64_t col_count)
|
||||
{
|
||||
ObPhysicalPlanCtx* plan_ctx = NULL;
|
||||
ObPhysicalPlanCtx *plan_ctx = NULL;
|
||||
|
||||
scalar_aggr_op.reset();
|
||||
scalar_aggr_op.reuse();
|
||||
@ -141,10 +150,11 @@ public:
|
||||
ASSERT_EQ(OB_SUCCESS, my_session_.init_tenant(ObString::make_string("sys"), 1));
|
||||
ASSERT_EQ(OB_SUCCESS, ObPreProcessSysVars::init_sys_var());
|
||||
ASSERT_EQ(OB_SUCCESS, my_session_.load_default_sys_variable(false, true));
|
||||
ASSERT_EQ(OB_SUCCESS, my_session_.load_default_configs_in_pc());
|
||||
|
||||
scalar_aggr_op.init(10);
|
||||
fake_table_.set_column_count(col_count);
|
||||
result_table_.set_column_count(col_count + 3); // avg(c), avg(b), avg(a)
|
||||
result_table_.set_column_count(col_count + 3); // avg(c), avg(b), avg(a)
|
||||
scalar_aggr_op.set_column_count(col_count + 3);
|
||||
|
||||
fake_table_.set_id(0);
|
||||
@ -157,8 +167,8 @@ public:
|
||||
|
||||
scalar_aggr_op.set_child(0, fake_table_);
|
||||
|
||||
ASSERT_EQ(OB_SUCCESS, ctx.init_phy_op(3));
|
||||
ctx.set_my_session(&my_session_);
|
||||
ASSERT_EQ(OB_SUCCESS, ctx.init_phy_op(3));
|
||||
ASSERT_EQ(OB_SUCCESS, ctx.create_physical_plan_ctx());
|
||||
plan_ctx = ctx.get_physical_plan_ctx();
|
||||
ASSERT_FALSE(NULL == plan_ctx);
|
||||
@ -166,54 +176,46 @@ public:
|
||||
add_aggr_column(scalar_aggr_op);
|
||||
}
|
||||
|
||||
static void open_operator(ObExecContext& ctx, ObGroupBy& groupby_op)
|
||||
static void open_operator(ObExecContext &ctx, ObGroupBy &groupby_op)
|
||||
{
|
||||
ObPhyOperator* op = static_cast<ObPhyOperator*>(&groupby_op);
|
||||
ObPhyOperator *op = static_cast<ObPhyOperator *>(&groupby_op);
|
||||
ASSERT_EQ(OB_SUCCESS, op->open(ctx));
|
||||
ASSERT_EQ(OB_SUCCESS, result_table_.open(ctx));
|
||||
}
|
||||
|
||||
static void close_operator(ObExecContext& ctx, ObGroupBy& groupby_op)
|
||||
static void close_operator(ObExecContext &ctx, ObGroupBy &groupby_op)
|
||||
{
|
||||
ObPhyOperator* op = static_cast<ObPhyOperator*>(&groupby_op);
|
||||
ObPhyOperator *op = static_cast<ObPhyOperator *>(&groupby_op);
|
||||
ASSERT_EQ(OB_SUCCESS, op->close(ctx));
|
||||
ASSERT_EQ(OB_SUCCESS, result_table_.close(ctx));
|
||||
}
|
||||
|
||||
static void open_operator(ObExecContext& ctx, ObScalarAggregate& groupby_op)
|
||||
static void open_operator(ObExecContext &ctx, ObScalarAggregate &groupby_op)
|
||||
{
|
||||
ObPhyOperator* op = static_cast<ObPhyOperator*>(&groupby_op);
|
||||
ObPhyOperator *op = static_cast<ObPhyOperator *>(&groupby_op);
|
||||
ASSERT_EQ(OB_SUCCESS, op->open(ctx));
|
||||
ASSERT_EQ(OB_SUCCESS, result_table_.open(ctx));
|
||||
}
|
||||
|
||||
static void close_operator(ObExecContext& ctx, ObScalarAggregate& groupby_op)
|
||||
static void close_operator(ObExecContext &ctx, ObScalarAggregate &groupby_op)
|
||||
{
|
||||
ObPhyOperator* op = static_cast<ObPhyOperator*>(&groupby_op);
|
||||
ObPhyOperator *op = static_cast<ObPhyOperator *>(&groupby_op);
|
||||
ASSERT_EQ(OB_SUCCESS, op->close(ctx));
|
||||
ASSERT_EQ(OB_SUCCESS, result_table_.close(ctx));
|
||||
}
|
||||
|
||||
static ObFakeTable& get_fake_table()
|
||||
{
|
||||
return fake_table_;
|
||||
}
|
||||
static ObFakeTable& get_result_table()
|
||||
{
|
||||
return result_table_;
|
||||
}
|
||||
static ObPhysicalPlan& get_physical_plan()
|
||||
{
|
||||
return physical_plan_;
|
||||
}
|
||||
|
||||
static ObFakeTable &get_fake_table() { return fake_table_; }
|
||||
static ObFakeTable &get_result_table() { return result_table_; }
|
||||
static ObPhysicalPlan &get_physical_plan() { return physical_plan_; }
|
||||
private:
|
||||
static void add_aggr_column(
|
||||
ObGroupBy& groupby_op, bool is_distinct, bool is_number = true, ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN)
|
||||
static void add_aggr_column(ObGroupBy &groupby_op,
|
||||
bool is_distinct,
|
||||
bool is_number = true,
|
||||
ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN)
|
||||
{
|
||||
ObAggregateExpression* col_expr = NULL;
|
||||
ObAggregateExpression *col_expr = NULL;
|
||||
ObPostExprItem expr_item;
|
||||
// count(aggr_col)
|
||||
//count(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->reset();
|
||||
col_expr->set_item_count(1);
|
||||
@ -226,7 +228,7 @@ private:
|
||||
col_expr->add_aggr_cs_type(agg_cs_type);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
groupby_op.add_aggr_column(col_expr);
|
||||
// max(aggr_col)
|
||||
//max(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(1);
|
||||
@ -238,7 +240,7 @@ private:
|
||||
col_expr->add_aggr_cs_type(agg_cs_type);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
groupby_op.add_aggr_column(col_expr);
|
||||
// min(aggr_col)
|
||||
//min(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(1);
|
||||
@ -250,9 +252,9 @@ private:
|
||||
col_expr->add_aggr_cs_type(agg_cs_type);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
groupby_op.add_aggr_column(col_expr);
|
||||
// functions used only for number
|
||||
//functions used only for number
|
||||
if (is_number) {
|
||||
// sum(aggr_col)
|
||||
//sum(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(1);
|
||||
@ -263,7 +265,7 @@ private:
|
||||
col_expr->add_aggr_cs_type(agg_cs_type);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
groupby_op.add_aggr_column(col_expr);
|
||||
// avg(aggr_col)
|
||||
//avg(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(1);
|
||||
@ -276,7 +278,7 @@ private:
|
||||
groupby_op.add_aggr_column(col_expr);
|
||||
}
|
||||
if (is_distinct) {
|
||||
// approx_count_distinct(aggr_col)
|
||||
//approx_count_distinct(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->reset();
|
||||
col_expr->set_item_count(1);
|
||||
@ -292,11 +294,11 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static void add_aggr_column(ObScalarAggregate& scalar_aggr_op)
|
||||
static void add_aggr_column(ObScalarAggregate &scalar_aggr_op)
|
||||
{
|
||||
ObAggregateExpression* col_expr = NULL;
|
||||
ObAggregateExpression *col_expr = NULL;
|
||||
ObPostExprItem expr_item;
|
||||
// avg(c)
|
||||
//avg(c)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(0);
|
||||
@ -305,7 +307,7 @@ private:
|
||||
col_expr->set_aggr_func(T_FUN_AVG, false);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
scalar_aggr_op.add_aggr_column(col_expr);
|
||||
// avg(b)
|
||||
//avg(b)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(1);
|
||||
@ -314,7 +316,7 @@ private:
|
||||
col_expr->set_aggr_func(T_FUN_AVG, false);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
scalar_aggr_op.add_aggr_column(col_expr);
|
||||
// avg(a)
|
||||
//avg(a)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(2);
|
||||
@ -325,12 +327,14 @@ private:
|
||||
scalar_aggr_op.add_aggr_column(col_expr);
|
||||
}
|
||||
|
||||
static void add_aggr_column(ObScalarAggregate& scalar_aggr_op, bool is_distinct, bool is_number = true,
|
||||
ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN)
|
||||
static void add_aggr_column(ObScalarAggregate &scalar_aggr_op,
|
||||
bool is_distinct,
|
||||
bool is_number = true,
|
||||
ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN)
|
||||
{
|
||||
ObAggregateExpression* col_expr = NULL;
|
||||
ObAggregateExpression *col_expr = NULL;
|
||||
ObPostExprItem expr_item;
|
||||
// count(aggr_col)
|
||||
//count(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->reset();
|
||||
col_expr->set_item_count(1);
|
||||
@ -343,7 +347,7 @@ private:
|
||||
col_expr->add_aggr_cs_type(agg_cs_type);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
scalar_aggr_op.add_aggr_column(col_expr);
|
||||
// max(aggr_col)
|
||||
//max(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(1);
|
||||
@ -355,7 +359,7 @@ private:
|
||||
col_expr->add_aggr_cs_type(agg_cs_type);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
scalar_aggr_op.add_aggr_column(col_expr);
|
||||
// min(aggr_col)
|
||||
//min(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(1);
|
||||
@ -367,11 +371,11 @@ private:
|
||||
col_expr->add_aggr_cs_type(agg_cs_type);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
scalar_aggr_op.add_aggr_column(col_expr);
|
||||
// functions used only for number
|
||||
//functions used only for number
|
||||
if (is_number) {
|
||||
// sum(aggr_col)
|
||||
//sum(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(1);
|
||||
col_expr->add_expr_item(expr_item);
|
||||
col_expr->set_result_index(6);
|
||||
@ -380,9 +384,9 @@ private:
|
||||
col_expr->add_aggr_cs_type(agg_cs_type);
|
||||
col_expr->set_real_param_col_count(1);
|
||||
scalar_aggr_op.add_aggr_column(col_expr);
|
||||
// avg(aggr_col)
|
||||
//avg(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->set_item_count(1);
|
||||
col_expr->set_item_count(1);
|
||||
expr_item.set_column(1);
|
||||
col_expr->add_expr_item(expr_item);
|
||||
col_expr->set_result_index(7);
|
||||
@ -393,7 +397,7 @@ private:
|
||||
scalar_aggr_op.add_aggr_column(col_expr);
|
||||
}
|
||||
if (is_distinct) {
|
||||
// approx_count_distinct(aggr_col)
|
||||
//approx_count_distinct(aggr_col)
|
||||
ASSERT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(&physical_plan_, col_expr));
|
||||
col_expr->reset();
|
||||
col_expr->set_item_count(1);
|
||||
@ -408,7 +412,6 @@ private:
|
||||
scalar_aggr_op.add_aggr_column(col_expr);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static ObPhysicalPlan physical_plan_;
|
||||
static ObFakeTable fake_table_;
|
||||
|
@ -24,13 +24,18 @@
|
||||
#include "share/config/ob_server_config.h"
|
||||
#include "share/ob_define.h"
|
||||
#include "observer/omt/ob_tenant_config_mgr.h"
|
||||
#include "share/ob_simple_mem_limit_getter.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace omt;
|
||||
namespace sql {
|
||||
namespace sql
|
||||
{
|
||||
using namespace common;
|
||||
static ObSimpleMemLimitGetter getter;
|
||||
|
||||
class TestEnv : public ::testing::Environment {
|
||||
class TestEnv : public ::testing::Environment
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override
|
||||
{
|
||||
@ -38,7 +43,7 @@ public:
|
||||
uint64_t cluster_version = CLUSTER_VERSION_3000;
|
||||
common::ObClusterVersion::get_instance().update_cluster_version(cluster_version);
|
||||
int ret = OB_SUCCESS;
|
||||
lib::ObMallocAllocator* malloc_allocator = lib::ObMallocAllocator::get_instance();
|
||||
lib::ObMallocAllocator *malloc_allocator = lib::ObMallocAllocator::get_instance();
|
||||
ret = malloc_allocator->create_tenant_ctx_allocator(OB_SYS_TENANT_ID);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = malloc_allocator->create_tenant_ctx_allocator(OB_SYS_TENANT_ID, common::ObCtxIds::WORK_AREA);
|
||||
@ -49,29 +54,29 @@ public:
|
||||
}
|
||||
|
||||
virtual void TearDown() override
|
||||
{}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#define CALL(func, ...) \
|
||||
func(__VA_ARGS__); \
|
||||
ASSERT_FALSE(HasFatalFailure());
|
||||
#define CALL(func, ...) func(__VA_ARGS__); ASSERT_FALSE(HasFatalFailure());
|
||||
|
||||
class TestHashDistinct : public ObHashDistinct {
|
||||
|
||||
class TestHashDistinct : public ObHashDistinct
|
||||
{
|
||||
public:
|
||||
TestHashDistinct() : ObHashDistinct(alloc_)
|
||||
{}
|
||||
~TestHashDistinct()
|
||||
{}
|
||||
TestHashDistinct() :ObHashDistinct(alloc_) {}
|
||||
~TestHashDistinct() {}
|
||||
};
|
||||
|
||||
#define CALL(func, ...) \
|
||||
func(__VA_ARGS__); \
|
||||
ASSERT_FALSE(HasFatalFailure());
|
||||
#define CALL(func, ...) func(__VA_ARGS__); ASSERT_FALSE(HasFatalFailure());
|
||||
|
||||
class TestHashDistinctTest : public blocksstable::TestDataFilePrepare {
|
||||
class TestHashDistinctTest: public blocksstable::TestDataFilePrepare
|
||||
{
|
||||
public:
|
||||
TestHashDistinctTest() : blocksstable::TestDataFilePrepare("TestDisk_distinct", 2 << 20, 5000)
|
||||
{}
|
||||
TestHashDistinctTest() : blocksstable::TestDataFilePrepare(&getter,
|
||||
"TestDisk_distinct", 2<<20, 5000)
|
||||
{
|
||||
}
|
||||
virtual ~TestHashDistinctTest();
|
||||
virtual void SetUp() override
|
||||
{
|
||||
@ -81,8 +86,6 @@ public:
|
||||
blocksstable::TestDataFilePrepare::SetUp();
|
||||
ret = blocksstable::ObTmpFileManager::get_instance().init();
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = blocksstable::ObTmpFileManager::get_instance().start();
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
row_.count_ = COLS;
|
||||
row_.cells_ = cells_;
|
||||
@ -104,116 +107,119 @@ public:
|
||||
{
|
||||
blocksstable::ObTmpFileManager::get_instance().destroy();
|
||||
blocksstable::TestDataFilePrepare::TearDown();
|
||||
common::ObModItem mod;
|
||||
lib::get_tenant_mod_memory(tenant_id_, static_cast<int>(mod_id_), mod);
|
||||
ASSERT_EQ(0, mod.hold_);
|
||||
lib::get_tenant_mod_memory(tenant_id_, static_cast<int>(mod_id2_), mod);
|
||||
ASSERT_EQ(0, mod.hold_);
|
||||
lib::get_tenant_mod_memory(tenant_id_, static_cast<int>(mod_id3_), mod);
|
||||
ASSERT_EQ(0, mod.hold_);
|
||||
ObTenantManager::get_instance().destroy();
|
||||
SQL_ENG_LOG(WARN, "TearDown finished");
|
||||
common::ObLabelItem item;
|
||||
lib::get_tenant_label_memory(tenant_id_, ObNewModIds::TEST1, item);
|
||||
ASSERT_EQ(0, item.hold_);
|
||||
lib::get_tenant_label_memory(tenant_id_, ObNewModIds::TEST2, item);
|
||||
ASSERT_EQ(0, item.hold_);
|
||||
lib::get_tenant_label_memory(tenant_id_, ObNewModIds::TEST3, item);
|
||||
ASSERT_EQ(0, item.hold_);
|
||||
SQL_ENG_LOG(WARN,"TearDown finished");
|
||||
}
|
||||
|
||||
ObNewRow& gen_row(int64_t row_id)
|
||||
|
||||
ObNewRow &gen_row(int64_t row_id)
|
||||
{
|
||||
cells_[0].set_int(row_id);
|
||||
int64_t max_size = 512;
|
||||
if (enable_big_row_ && row_id > 0 && random() % 100000 < 5) {
|
||||
max_size = 1 << 20;
|
||||
max_size = 1 << 20;
|
||||
}
|
||||
int64_t size = 10 + random() % max_size;
|
||||
cells_[2].set_varchar(str_buf_, (int)size);
|
||||
return row_;
|
||||
}
|
||||
|
||||
// varify next row
|
||||
// template <typename T>
|
||||
void verify_row(ObExecContext& ctx, TestHashDistinct& op, bool verify_all = false)
|
||||
{
|
||||
const ObNewRow* result_row = &row_verify_;
|
||||
int ret = op.get_next_row(ctx, result_row);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
//varify next row
|
||||
//template <typename T>
|
||||
void verify_row(ObExecContext &ctx, TestHashDistinct &op, bool verify_all = false)
|
||||
{
|
||||
const ObNewRow *result_row = &row_verify_;
|
||||
int ret = op.get_next_row(ctx, result_row);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
int64_t v;
|
||||
result_row->get_cell(0).get_int(v);
|
||||
if (verify_all) {
|
||||
result_row->get_cell(1).is_null();
|
||||
ObString s = result_row->get_cell(2).get_varchar();
|
||||
if (0 != strncmp(str_buf_, s.ptr(), s.length())) {
|
||||
SQL_ENG_LOG(WARN, "verify failed", K(s.ptr()), K(s.length()));
|
||||
}
|
||||
ASSERT_EQ(0, strncmp(str_buf_, s.ptr(), s.length()));
|
||||
}
|
||||
int64_t v;
|
||||
result_row->get_cell(0).get_int(v);
|
||||
if (verify_all) {
|
||||
result_row->get_cell(1).is_null();
|
||||
ObString s = result_row->get_cell(2).get_varchar();
|
||||
if (0 != strncmp(str_buf_, s.ptr(), s.length())) {
|
||||
SQL_ENG_LOG(WARN, "verify failed", K(s.ptr()), K(s.length()));
|
||||
}
|
||||
ASSERT_EQ(0, strncmp(str_buf_, s.ptr(), s.length()));
|
||||
}
|
||||
|
||||
ASSERT_EQ(hit_val[v], '0');
|
||||
hit_val[v] = 1;
|
||||
}
|
||||
ASSERT_EQ(hit_val[v], '0');
|
||||
hit_val[v] = 1;
|
||||
}
|
||||
|
||||
void verify_n_rows(ObExecContext& ctx, TestHashDistinct& op, int64_t n, bool verify_all = false, int64_t start = 0)
|
||||
{
|
||||
memset(hit_val, '0', BUF_SIZE);
|
||||
void verify_n_rows(ObExecContext &ctx, TestHashDistinct &op,
|
||||
int64_t n, bool verify_all = false, int64_t start = 0)
|
||||
{
|
||||
memset(hit_val, '0', BUF_SIZE);
|
||||
|
||||
for (int64_t i = start; i < n; i++) {
|
||||
CALL(verify_row, ctx, op, verify_all);
|
||||
}
|
||||
for (int64_t i = start; i < n; i++) {
|
||||
CALL(verify_row, ctx, op, verify_all);
|
||||
}
|
||||
|
||||
ASSERT_EQ(0, memcpy(hit_val, hit_val_base, sizeof(char) * n));
|
||||
}
|
||||
ASSERT_EQ(0, memcpy(hit_val, hit_val_base, sizeof(char) * n));
|
||||
}
|
||||
|
||||
void verify_all_rows(ObExecContext& ctx, TestHashDistinct& op, int64_t n, bool verify_all = false)
|
||||
{
|
||||
int64_t i = 0;
|
||||
int64_t v;
|
||||
memset(hit_val, '0', BUF_SIZE);
|
||||
while (true) {
|
||||
const ObNewRow* result_row = &row_verify_;
|
||||
int ret = op.get_next_row(ctx, result_row);
|
||||
if (OB_ITER_END == ret) {
|
||||
break;
|
||||
}
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
i++;
|
||||
result_row->get_cell(0).get_int(v);
|
||||
if (verify_all) {
|
||||
result_row->get_cell(1).is_null();
|
||||
ObString s = result_row->get_cell(2).get_varchar();
|
||||
if (0 != strncmp(str_buf_, s.ptr(), s.length())) {
|
||||
SQL_ENG_LOG(WARN, "verify failed", K(s.ptr()), K(s.length()), K(v), K(i));
|
||||
void verify_all_rows(ObExecContext &ctx, TestHashDistinct &op,
|
||||
int64_t n, bool verify_all = false)
|
||||
{
|
||||
int64_t i = 0;
|
||||
int64_t v;
|
||||
memset(hit_val, '0', BUF_SIZE);
|
||||
while (true) {
|
||||
const ObNewRow *result_row = &row_verify_;
|
||||
int ret = op.get_next_row(ctx, result_row);
|
||||
if (OB_ITER_END == ret)
|
||||
{
|
||||
break;
|
||||
}
|
||||
ASSERT_EQ(0, strncmp(str_buf_, s.ptr(), s.length()));
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
i++;
|
||||
result_row->get_cell(0).get_int(v);
|
||||
if (verify_all) {
|
||||
result_row->get_cell(1).is_null();
|
||||
ObString s = result_row->get_cell(2).get_varchar();
|
||||
if (0 != strncmp(str_buf_, s.ptr(), s.length())) {
|
||||
SQL_ENG_LOG(WARN, "verify failed", K(s.ptr()), K(s.length()), K(v), K(i));
|
||||
}
|
||||
ASSERT_EQ(0, strncmp(str_buf_, s.ptr(), s.length()));
|
||||
}
|
||||
if (hit_val[v] != '0') {
|
||||
SQL_ENG_LOG(WARN, "alread hitted", K(i), K(v));
|
||||
}
|
||||
ASSERT_EQ(hit_val[v], '0');
|
||||
hit_val[v] = '1';
|
||||
}
|
||||
if (hit_val[v] != '0') {
|
||||
SQL_ENG_LOG(WARN, "alread hitted", K(i), K(v));
|
||||
if (n != i) {
|
||||
SQL_ENG_LOG(WARN, "already hitted", K(i), K(v));
|
||||
}
|
||||
ASSERT_EQ(hit_val[v], '0');
|
||||
hit_val[v] = '1';
|
||||
ASSERT_EQ(n, i);
|
||||
ASSERT_EQ(0, MEMCMP(hit_val, hit_val_base, sizeof(char) * n));
|
||||
}
|
||||
if (n != i) {
|
||||
SQL_ENG_LOG(WARN, "already hitted", K(i), K(v));
|
||||
}
|
||||
ASSERT_EQ(n, i);
|
||||
ASSERT_EQ(0, MEMCMP(hit_val, hit_val_base, sizeof(char) * n));
|
||||
}
|
||||
|
||||
void append_rows(int64_t cnt)
|
||||
{
|
||||
int64_t ret = OB_SUCCESS;
|
||||
// int64_t base = fake_table_.get_rows();
|
||||
for (int64_t i = 0; i < cnt; i++) {
|
||||
ObNewRow& row = gen_row(i);
|
||||
fake_table_.add_row(row);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
// if (i % 1000 == 0) {
|
||||
// LOG_WARN("appended rows:", K(i));
|
||||
//}
|
||||
}
|
||||
// ASSERT_EQ(base + cnt, fake_table_.get_rows());
|
||||
}
|
||||
void append_rows(int64_t cnt)
|
||||
{
|
||||
int64_t ret = OB_SUCCESS;
|
||||
//int64_t base = fake_table_.get_rows();
|
||||
for (int64_t i = 0; i < cnt; i++) {
|
||||
ObNewRow &row = gen_row(i);
|
||||
fake_table_.add_row(row);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
//if (i % 1000 == 0) {
|
||||
// LOG_WARN("appended rows:", K(i));
|
||||
//}
|
||||
}
|
||||
//ASSERT_EQ(base + cnt, fake_table_.get_rows());
|
||||
}
|
||||
|
||||
void init(ObExecContext& ctx, ObSQLSessionInfo& my_session, TestHashDistinct& hash_distinct, int64_t col_count)
|
||||
void init(ObExecContext &ctx, ObSQLSessionInfo &my_session, TestHashDistinct &hash_distinct, int64_t col_count)
|
||||
{
|
||||
ASSERT_EQ(OB_SUCCESS, my_session.test_init(0, 0, 0, NULL));
|
||||
ASSERT_EQ(OB_SUCCESS, my_session.test_init(0,0,0,NULL));
|
||||
ASSERT_EQ(OB_SUCCESS, ObPreProcessSysVars::init_sys_var());
|
||||
ASSERT_EQ(OB_SUCCESS, my_session.load_default_sys_variable(false, true));
|
||||
ASSERT_EQ(OB_SUCCESS, my_session.init_tenant("test", OB_SYS_TENANT_ID));
|
||||
@ -250,41 +256,30 @@ public:
|
||||
ctx.get_physical_plan_ctx()->set_phy_plan(&physical_plan_);
|
||||
}
|
||||
|
||||
void open_operator(ObExecContext& ctx, TestHashDistinct& hash_distinct)
|
||||
void open_operator(ObExecContext &ctx, TestHashDistinct &hash_distinct)
|
||||
{
|
||||
ASSERT_EQ(OB_SUCCESS, hash_distinct.open(ctx));
|
||||
ObHashDistinct::ObHashDistinctCtx* distinct_ctx = NULL;
|
||||
bool is_null =
|
||||
OB_ISNULL(distinct_ctx = GET_PHY_OPERATOR_CTX(ObHashDistinct::ObHashDistinctCtx, ctx, hash_distinct.get_id()));
|
||||
ObHashDistinct::ObHashDistinctCtx *distinct_ctx = NULL;
|
||||
bool is_null = OB_ISNULL(distinct_ctx = GET_PHY_OPERATOR_CTX(ObHashDistinct::ObHashDistinctCtx, ctx, hash_distinct.get_id()));
|
||||
ASSERT_EQ(is_null, false);
|
||||
distinct_ctx->enable_sql_dumped_ = true;
|
||||
ASSERT_EQ(OB_SUCCESS, result_table_.open(ctx));
|
||||
}
|
||||
|
||||
void close_operator(ObExecContext& ctx, TestHashDistinct& hash_distinct)
|
||||
void close_operator(ObExecContext &ctx, TestHashDistinct &hash_distinct)
|
||||
{
|
||||
ASSERT_EQ(OB_SUCCESS, hash_distinct.close(ctx));
|
||||
ASSERT_EQ(OB_SUCCESS, result_table_.close(ctx));
|
||||
}
|
||||
|
||||
ObFakeTable& get_fake_table()
|
||||
{
|
||||
return fake_table_;
|
||||
}
|
||||
ObFakeTable& get_result_table()
|
||||
{
|
||||
return result_table_;
|
||||
}
|
||||
ObPhysicalPlan& get_physical_plan()
|
||||
{
|
||||
return physical_plan_;
|
||||
}
|
||||
|
||||
ObFakeTable &get_fake_table() { return fake_table_; }
|
||||
ObFakeTable &get_result_table() { return result_table_; }
|
||||
ObPhysicalPlan &get_physical_plan() { return physical_plan_; }
|
||||
protected:
|
||||
ObFakeTable fake_table_;
|
||||
ObFakeTable result_table_;
|
||||
ObPhysicalPlan physical_plan_;
|
||||
int32_t projector[3] = {0, 1, 2};
|
||||
int32_t projector[3] = {0,1,2};
|
||||
|
||||
const static int64_t COLS = 3;
|
||||
bool enable_big_row_ = false;
|
||||
@ -300,24 +295,20 @@ protected:
|
||||
private:
|
||||
int64_t tenant_id_ = OB_SYS_TENANT_ID;
|
||||
int64_t ctx_id_ = ObCtxIds::WORK_AREA;
|
||||
int64_t mod_id_ = ObNewModIds::TEST1;
|
||||
int64_t mod_id2_ = ObNewModIds::TEST2;
|
||||
int64_t mod_id3_ = ObNewModIds::TEST3;
|
||||
// disallow copy
|
||||
TestHashDistinctTest(const TestHashDistinctTest& other);
|
||||
TestHashDistinctTest& operator=(const TestHashDistinctTest& other);
|
||||
|
||||
TestHashDistinctTest(const TestHashDistinctTest &other);
|
||||
TestHashDistinctTest& operator=(const TestHashDistinctTest &other);
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
|
||||
TestHashDistinctTest::~TestHashDistinctTest()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int TestHashDistinctTest::init_tenant_mgr()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTenantManager& tm = ObTenantManager::get_instance();
|
||||
ObAddr self;
|
||||
oceanbase::rpc::frame::ObReqTransport req_transport(NULL, NULL);
|
||||
oceanbase::obrpc::ObSrvRpcProxy rpc_proxy;
|
||||
@ -330,30 +321,26 @@ int TestHashDistinctTest::init_tenant_mgr()
|
||||
GCONF.enable_sql_operator_dump.set_value("True");
|
||||
uint64_t cluster_version = CLUSTER_VERSION_3000;
|
||||
common::ObClusterVersion::get_instance().update_cluster_version(cluster_version);
|
||||
ret = tm.init(self, rpc_proxy, rs_rpc_proxy, rs_mgr, &req_transport, &ObServerConfig::get_instance());
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
ret = tm.add_tenant(tenant_id);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
ret = tm.set_tenant_mem_limit(tenant_id, 2L * 1024L * 1024L * 1024L, 4L * 1024L * 1024L * 1024L);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
ret = tm.add_tenant(OB_SYS_TENANT_ID);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
ret = tm.add_tenant(OB_SERVER_TENANT_ID);
|
||||
ret = getter.add_tenant(tenant_id,
|
||||
2L * 1024L * 1024L * 1024L, 4L * 1024L * 1024L * 1024L);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
const int64_t ulmt = 128LL << 30;
|
||||
const int64_t llmt = 128LL << 30;
|
||||
ret = tm.set_tenant_mem_limit(OB_SYS_TENANT_ID, ulmt, llmt);
|
||||
ret = getter.add_tenant(OB_SERVER_TENANT_ID,
|
||||
ulmt,
|
||||
llmt);
|
||||
EXPECT_EQ(OB_SUCCESS, ret);
|
||||
oceanbase::lib::set_memory_limit(128LL << 32);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
TEST_F(TestHashDistinctTest, test_big_data00)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
@ -361,13 +348,13 @@ TEST_F(TestHashDistinctTest, test_big_data00)
|
||||
|
||||
enable_big_row_ = true;
|
||||
hash_distinct.set_mem_limit(64 * 1024 * 1024 * 10);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
CALL(append_rows, 1000000);
|
||||
CALL(append_rows, 1000000);
|
||||
|
||||
hash_distinct.init(1);
|
||||
hash_distinct.add_distinct_column(0, cs_type);
|
||||
// hash_distinct.add_distinct_column(1, cs_type);
|
||||
//hash_distinct.add_distinct_column(1, cs_type);
|
||||
open_operator(ctx, hash_distinct);
|
||||
CALL(verify_all_rows, ctx, hash_distinct, 1000000, true);
|
||||
close_operator(ctx, hash_distinct);
|
||||
@ -377,8 +364,8 @@ TEST_F(TestHashDistinctTest, test_big_data01)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
@ -386,7 +373,7 @@ TEST_F(TestHashDistinctTest, test_big_data01)
|
||||
|
||||
enable_big_row_ = true;
|
||||
hash_distinct.set_mem_limit(64 * 1024 * 1024 * 10);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
CALL(append_rows, 1000000);
|
||||
CALL(append_rows, 100000);
|
||||
CALL(append_rows, 1000000);
|
||||
@ -395,24 +382,26 @@ TEST_F(TestHashDistinctTest, test_big_data01)
|
||||
|
||||
hash_distinct.init(1);
|
||||
hash_distinct.add_distinct_column(0, cs_type);
|
||||
// hash_distinct.add_distinct_column(1, cs_type);
|
||||
//hash_distinct.add_distinct_column(1, cs_type);
|
||||
open_operator(ctx, hash_distinct);
|
||||
CALL(verify_all_rows, ctx, hash_distinct, 1000000, true);
|
||||
close_operator(ctx, hash_distinct);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_F(TestHashDistinctTest, test_utf8mb4_bin)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_BIN;
|
||||
ObSQLSessionInfo my_session;
|
||||
init(ctx, my_session, hash_distinct, 3);
|
||||
// fake table: distinct column(c1)
|
||||
ADD_ROW(fake_table, COL("r"), COL(1), COL(1));
|
||||
//fake table: distinct column(c1)
|
||||
ADD_ROW(fake_table, COL("r"), COL(1), COL(1));
|
||||
ADD_ROW(fake_table, COL("r"), COL(1), COL(2));
|
||||
ADD_ROW(fake_table, COL("s"), COL(2), COL(3));
|
||||
ADD_ROW(fake_table, COL("s"), COL(1), COL(3));
|
||||
@ -439,13 +428,13 @@ TEST_F(TestHashDistinctTest, test_utf8mb4_general_ci)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
init(ctx, my_session, hash_distinct, 3);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
ADD_ROW(fake_table, COL("r"), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL("r"), COL("r"), COL(2));
|
||||
ADD_ROW(fake_table, COL("s"), COL("s"), COL(3));
|
||||
@ -474,15 +463,15 @@ TEST_F(TestHashDistinctTest, test_all_in_mem)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
init(ctx, my_session, hash_distinct, 3);
|
||||
|
||||
hash_distinct.set_mem_limit(64 * 1024 * 1024);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
CALL(append_rows, 1000);
|
||||
|
||||
fake_table_.set_rows(1000);
|
||||
@ -501,15 +490,15 @@ TEST_F(TestHashDistinctTest, test_all_in_mem1)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
init(ctx, my_session, hash_distinct, 3);
|
||||
|
||||
hash_distinct.set_mem_limit(64 * 1024 * 1024);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
CALL(append_rows, 3000);
|
||||
|
||||
fake_table_.set_rows(3000);
|
||||
@ -528,15 +517,15 @@ TEST_F(TestHashDistinctTest, test_all_in_mem2)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
init(ctx, my_session, hash_distinct, 3);
|
||||
|
||||
hash_distinct.set_mem_limit(64 * 1024 * 1024 * 10);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
CALL(append_rows, 3000);
|
||||
CALL(append_rows, 3000);
|
||||
CALL(append_rows, 3000);
|
||||
@ -545,17 +534,18 @@ TEST_F(TestHashDistinctTest, test_all_in_mem2)
|
||||
hash_distinct.add_distinct_column(0, cs_type);
|
||||
hash_distinct.add_distinct_column(1, cs_type);
|
||||
open_operator(ctx, hash_distinct);
|
||||
// ASSERT_EQ(3000, hash_distinct.get_rows());
|
||||
//ASSERT_EQ(3000, hash_distinct.get_rows());
|
||||
CALL(verify_all_rows, ctx, hash_distinct, 3000, true);
|
||||
close_operator(ctx, hash_distinct);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(TestHashDistinctTest, test_big_data)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
@ -563,7 +553,7 @@ TEST_F(TestHashDistinctTest, test_big_data)
|
||||
|
||||
enable_big_row_ = true;
|
||||
hash_distinct.set_mem_limit(64 * 1024 * 1024 * 10);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
CALL(append_rows, 20000);
|
||||
|
||||
hash_distinct.init(2);
|
||||
@ -574,6 +564,7 @@ TEST_F(TestHashDistinctTest, test_big_data)
|
||||
close_operator(ctx, hash_distinct);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(TestHashDistinctTest, test_big_data2)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -585,7 +576,7 @@ TEST_F(TestHashDistinctTest, test_big_data2)
|
||||
|
||||
enable_big_row_ = true;
|
||||
hash_distinct.set_mem_limit(64 * 1024 * 1024 * 10);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
CALL(append_rows, 20000);
|
||||
CALL(append_rows, 20000);
|
||||
CALL(append_rows, 20000);
|
||||
@ -598,12 +589,13 @@ TEST_F(TestHashDistinctTest, test_big_data2)
|
||||
close_operator(ctx, hash_distinct);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(TestHashDistinctTest, test_big_data3)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
@ -611,7 +603,7 @@ TEST_F(TestHashDistinctTest, test_big_data3)
|
||||
|
||||
enable_big_row_ = true;
|
||||
hash_distinct.set_mem_limit(64 * 1024 * 1024 * 10);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
CALL(append_rows, 50000);
|
||||
CALL(append_rows, 50000);
|
||||
CALL(append_rows, 50000);
|
||||
@ -628,8 +620,8 @@ TEST_F(TestHashDistinctTest, test_big_data4)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestHashDistinct hash_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
@ -637,7 +629,7 @@ TEST_F(TestHashDistinctTest, test_big_data4)
|
||||
|
||||
enable_big_row_ = true;
|
||||
hash_distinct.set_mem_limit(64 * 1024 * 1024 * 10);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
CALL(append_rows, 1000000);
|
||||
CALL(append_rows, 1000000);
|
||||
CALL(append_rows, 1000000);
|
||||
@ -652,17 +644,20 @@ TEST_F(TestHashDistinctTest, test_big_data4)
|
||||
close_operator(ctx, hash_distinct);
|
||||
}
|
||||
|
||||
} // end namespace sql
|
||||
} // end namespace oceanbase
|
||||
|
||||
int main(int argc, char** argv)
|
||||
} // end namespace sql
|
||||
} // end namespace oceanbase
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
oceanbase::sql::init_sql_factories();
|
||||
oceanbase::common::ObLogger::get_logger().set_log_level("WARN");
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
auto* env = new (oceanbase::sql::TestEnv);
|
||||
auto *env = new (oceanbase::sql::TestEnv);
|
||||
testing::AddGlobalTestEnvironment(env);
|
||||
int ret = RUN_ALL_TESTS();
|
||||
OB_LOGGER.disable();
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#define private public
|
||||
#define protected public
|
||||
#include "sql/ob_sql_init.h"
|
||||
#include "sql/engine/aggregate/ob_hash_groupby.h"
|
||||
#include "sql/engine/aggregate/ob_aggregate_test_utils.h"
|
||||
@ -18,37 +20,42 @@
|
||||
#include "storage/memtable/ob_row_compactor.h"
|
||||
#include "sql/engine/test_engine_util.h"
|
||||
#include "storage/blocksstable/ob_data_file_prepare.h"
|
||||
#include "share/ob_simple_mem_limit_getter.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
using namespace oceanbase::blocksstable;
|
||||
|
||||
class ObHashGroupbyTest : public TestDataFilePrepare {
|
||||
static ObSimpleMemLimitGetter getter;
|
||||
|
||||
class ObHashGroupbyTest: public TestDataFilePrepare
|
||||
{
|
||||
public:
|
||||
ObHashGroupbyTest();
|
||||
virtual ~ObHashGroupbyTest();
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
private:
|
||||
// disallow copy
|
||||
ObHashGroupbyTest(const ObHashGroupbyTest& other);
|
||||
ObHashGroupbyTest& operator=(const ObHashGroupbyTest& other);
|
||||
|
||||
ObHashGroupbyTest(const ObHashGroupbyTest &other);
|
||||
ObHashGroupbyTest& operator=(const ObHashGroupbyTest &other);
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
ObHashGroupbyTest::ObHashGroupbyTest() : TestDataFilePrepare("TestDisk_groupby", 2 << 20, 5000)
|
||||
{}
|
||||
ObHashGroupbyTest::ObHashGroupbyTest() : TestDataFilePrepare(&getter,
|
||||
"TestDisk_groupby", 2<<20, 5000)
|
||||
{
|
||||
}
|
||||
|
||||
ObHashGroupbyTest::~ObHashGroupbyTest()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void ObHashGroupbyTest::SetUp()
|
||||
{
|
||||
TestDataFilePrepare::SetUp();
|
||||
int ret = ObTmpFileManager::get_instance().init();
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
}
|
||||
|
||||
void ObHashGroupbyTest::TearDown()
|
||||
@ -56,12 +63,13 @@ void ObHashGroupbyTest::TearDown()
|
||||
ObTmpFileManager::get_instance().destroy();
|
||||
TestDataFilePrepare::TearDown();
|
||||
}
|
||||
class TestHashGroupBy : public ObHashGroupBy {
|
||||
class TestHashGroupBy : public ObHashGroupBy
|
||||
{
|
||||
public:
|
||||
TestHashGroupBy() : ObHashGroupBy(alloc_)
|
||||
{}
|
||||
virtual ~TestHashGroupBy()
|
||||
{}
|
||||
{
|
||||
}
|
||||
virtual ~TestHashGroupBy() {}
|
||||
};
|
||||
|
||||
TEST_F(ObHashGroupbyTest, test_utf8mb4_bin_agg)
|
||||
@ -69,8 +77,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_bin_agg)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestHashGroupBy hash_groupby;
|
||||
int64_t col_count = 3;
|
||||
bool is_distinct = false;
|
||||
@ -78,7 +86,7 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_bin_agg)
|
||||
ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN;
|
||||
ObCollationType group_cs_type = CS_TYPE_INVALID;
|
||||
TestAggregateFactory::init(ctx, hash_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(1));
|
||||
@ -86,7 +94,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_bin_agg)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL("ß"), COL("r"));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, hash_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby, col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby,
|
||||
col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, hash_groupby);
|
||||
}
|
||||
|
||||
@ -95,8 +104,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_genaral_ci_agg)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestHashGroupBy hash_groupby;
|
||||
int64_t col_count = 3;
|
||||
bool is_distinct = false;
|
||||
@ -105,7 +114,7 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_genaral_ci_agg)
|
||||
ObCollationType group_cs_type = CS_TYPE_INVALID;
|
||||
|
||||
TestAggregateFactory::init(ctx, hash_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(1));
|
||||
@ -113,7 +122,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_genaral_ci_agg)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL("t"), COL("r"));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, hash_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby, col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby,
|
||||
col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, hash_groupby);
|
||||
}
|
||||
|
||||
@ -122,8 +132,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_general_ci_group)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestHashGroupBy hash_groupby;
|
||||
int64_t col_count = 3;
|
||||
bool is_distinct = false;
|
||||
@ -132,7 +142,7 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_general_ci_group)
|
||||
ObCollationType group_cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
|
||||
TestAggregateFactory::init(ctx, hash_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL(2), COL("ß"));
|
||||
ADD_ROW(fake_table, COL(2), COL(4), COL("s"));
|
||||
ADD_ROW(fake_table, COL(3), COL(6), COL("ß"));
|
||||
@ -140,7 +150,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_general_ci_group)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL(8), COL(2), COL(20.0), COL(5.0));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, hash_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby, col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby,
|
||||
col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, hash_groupby);
|
||||
}
|
||||
|
||||
@ -149,8 +160,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_bin_agg_distinct)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestHashGroupBy hash_groupby;
|
||||
int64_t col_count = 3;
|
||||
bool is_distinct = true;
|
||||
@ -159,7 +170,7 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_bin_agg_distinct)
|
||||
ObCollationType group_cs_type = CS_TYPE_INVALID;
|
||||
|
||||
TestAggregateFactory::init(ctx, hash_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(1));
|
||||
@ -167,7 +178,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_bin_agg_distinct)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL("ß"), COL("r"), COL(4));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, hash_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby, col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby,
|
||||
col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, hash_groupby);
|
||||
}
|
||||
|
||||
@ -176,8 +188,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_general_ci_agg_distinct)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestHashGroupBy hash_groupby;
|
||||
int64_t col_count = 3;
|
||||
bool is_distinct = true;
|
||||
@ -186,7 +198,7 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_general_ci_agg_distinct)
|
||||
ObCollationType group_cs_type = CS_TYPE_INVALID;
|
||||
|
||||
TestAggregateFactory::init(ctx, hash_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(1));
|
||||
@ -194,7 +206,8 @@ TEST_F(ObHashGroupbyTest, test_utf8mb4_general_ci_agg_distinct)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(3), COL("t"), COL("r"), COL(3));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, hash_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby, col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, hash_groupby,
|
||||
col_count, hash_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, hash_groupby);
|
||||
}
|
||||
|
||||
@ -203,13 +216,13 @@ TEST_F(ObHashGroupbyTest, test_groupby_without_distinct)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestHashGroupBy hash_groupby;
|
||||
ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_BIN;
|
||||
|
||||
TestAggregateFactory::init(ctx, hash_groupby, 3, false);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL(1), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL(2), COL(2));
|
||||
ADD_ROW(fake_table, COL(5), COL(2), COL(3));
|
||||
@ -234,12 +247,12 @@ TEST_F(ObHashGroupbyTest, test_groupby_varchar)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestHashGroupBy hash_groupby;
|
||||
|
||||
TestAggregateFactory::init(ctx, hash_groupby, 3, false);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("1"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("2"), COL(2));
|
||||
ADD_ROW(fake_table, COL(5), COL("2"), COL(3));
|
||||
@ -264,12 +277,12 @@ TEST_F(ObHashGroupbyTest, test_groupby_with_distinct)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestHashGroupBy hash_groupby;
|
||||
|
||||
TestAggregateFactory::init(ctx, hash_groupby, 3, true);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL(1), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL(1), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL(2), COL(1));
|
||||
@ -296,7 +309,7 @@ TEST_F(ObHashGroupbyTest, test_invalid_argument)
|
||||
ObArenaAllocator alloc;
|
||||
ObFakeTable fake_table(alloc);
|
||||
TestHashGroupBy hash_groupby;
|
||||
const ObNewRow* row = NULL;
|
||||
const ObNewRow *row = NULL;
|
||||
|
||||
ASSERT_EQ(OB_NOT_INIT, hash_groupby.open(ctx));
|
||||
hash_groupby.reset();
|
||||
@ -321,15 +334,16 @@ TEST_F(ObHashGroupbyTest, test_invalid_argument1)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
TestHashGroupBy hash_groupby;
|
||||
ObArenaAllocator alloc;
|
||||
ObAggregateExpression col_expr(alloc);
|
||||
|
||||
TestAggregateFactory::init(ctx, hash_groupby, 3, false);
|
||||
// prepare rows, equal in the first row
|
||||
//prepare rows, equal in the first row
|
||||
ADD_ROW(fake_table, COL(1), COL(2), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL(2), COL(1));
|
||||
|
||||
}
|
||||
|
||||
TEST_F(ObHashGroupbyTest, test_serialize_and_deserialize)
|
||||
@ -354,16 +368,16 @@ TEST_F(ObHashGroupbyTest, test_serialize_and_deserialize)
|
||||
ASSERT_EQ(0, strcmp(to_cstring(hash_groupby), to_cstring(deserialize_op)));
|
||||
}
|
||||
|
||||
void __attribute__((constructor(101))) init_SessionDIBuffer()
|
||||
void __attribute__((constructor(101))) init_SessionDIBuffer()
|
||||
{
|
||||
oceanbase::common::ObDITls<ObSessionDIBuffer>::get_instance();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_global_memory_pool();
|
||||
init_sql_factories();
|
||||
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
::testing::InitGoogleTest(&argc,argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
@ -20,25 +20,25 @@
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
using namespace oceanbase::omt;
|
||||
class TestMergeDistinct : public ObMergeDistinct {
|
||||
class TestMergeDistinct : public ObMergeDistinct
|
||||
{
|
||||
public:
|
||||
TestMergeDistinct() : ObMergeDistinct(alloc_)
|
||||
{}
|
||||
~TestMergeDistinct()
|
||||
{}
|
||||
TestMergeDistinct() :ObMergeDistinct(alloc_) {}
|
||||
~TestMergeDistinct() {}
|
||||
};
|
||||
|
||||
class TestMergeDistinctTest : public ::testing::Test {
|
||||
class TestMergeDistinctTest: public ::testing::Test
|
||||
{
|
||||
public:
|
||||
TestMergeDistinctTest();
|
||||
virtual ~TestMergeDistinctTest();
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
void init(ObExecContext& ctx, TestMergeDistinct& merge_distinct, int64_t col_count)
|
||||
void init(ObExecContext &ctx, TestMergeDistinct &merge_distinct, int64_t col_count)
|
||||
{
|
||||
ASSERT_EQ(OB_SUCCESS,
|
||||
ObTenantConfigMgr::get_instance().add_tenant_config(ctx.get_my_session()->get_effective_tenant_id()));
|
||||
ASSERT_EQ(OB_SUCCESS, ObTenantConfigMgr::get_instance()
|
||||
.add_tenant_config(ctx.get_my_session()->get_effective_tenant_id()));
|
||||
|
||||
merge_distinct.reset();
|
||||
merge_distinct.reuse();
|
||||
@ -49,7 +49,7 @@ public:
|
||||
physical_plan_.reset();
|
||||
fake_table_.set_column_count(col_count);
|
||||
result_table_.set_column_count(col_count);
|
||||
int32_t projector[3] = {0, 1, 2};
|
||||
int32_t projector[3] = {0,1,2};
|
||||
result_table_.set_projector(projector, col_count);
|
||||
fake_table_.set_projector(projector, col_count);
|
||||
merge_distinct.set_projector(projector, col_count);
|
||||
@ -71,71 +71,63 @@ public:
|
||||
ctx.get_physical_plan_ctx()->set_phy_plan(&physical_plan_);
|
||||
}
|
||||
|
||||
void open_operator(ObExecContext& ctx, TestMergeDistinct& merge_distinct)
|
||||
void open_operator(ObExecContext &ctx, TestMergeDistinct &merge_distinct)
|
||||
{
|
||||
ASSERT_EQ(OB_SUCCESS, merge_distinct.open(ctx));
|
||||
ASSERT_EQ(OB_SUCCESS, result_table_.open(ctx));
|
||||
}
|
||||
|
||||
void close_operator(ObExecContext& ctx, TestMergeDistinct& merge_distinct)
|
||||
void close_operator(ObExecContext &ctx, TestMergeDistinct &merge_distinct)
|
||||
{
|
||||
ASSERT_EQ(OB_SUCCESS, merge_distinct.close(ctx));
|
||||
ASSERT_EQ(OB_SUCCESS, result_table_.close(ctx));
|
||||
}
|
||||
|
||||
ObFakeTable& get_fake_table()
|
||||
{
|
||||
return fake_table_;
|
||||
}
|
||||
ObFakeTable& get_result_table()
|
||||
{
|
||||
return result_table_;
|
||||
}
|
||||
ObPhysicalPlan& get_physical_plan()
|
||||
{
|
||||
return physical_plan_;
|
||||
}
|
||||
|
||||
ObFakeTable &get_fake_table() { return fake_table_; }
|
||||
ObFakeTable &get_result_table() { return result_table_; }
|
||||
ObPhysicalPlan &get_physical_plan() { return physical_plan_; }
|
||||
protected:
|
||||
ObFakeTable fake_table_;
|
||||
ObFakeTable result_table_;
|
||||
ObPhysicalPlan physical_plan_;
|
||||
|
||||
private:
|
||||
// disallow copy
|
||||
TestMergeDistinctTest(const TestMergeDistinctTest& other);
|
||||
TestMergeDistinctTest& operator=(const TestMergeDistinctTest& other);
|
||||
|
||||
TestMergeDistinctTest(const TestMergeDistinctTest &other);
|
||||
TestMergeDistinctTest& operator=(const TestMergeDistinctTest &other);
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
|
||||
TestMergeDistinctTest::TestMergeDistinctTest()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
TestMergeDistinctTest::~TestMergeDistinctTest()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void TestMergeDistinctTest::SetUp()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void TestMergeDistinctTest::TearDown()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
TEST_F(TestMergeDistinctTest, test_utf8mb4_bin)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestMergeDistinct merge_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_BIN;
|
||||
ObSQLSessionInfo my_session;
|
||||
ASSERT_EQ(OB_SUCCESS, my_session.test_init(0, 0, 0, NULL));
|
||||
ASSERT_EQ(OB_SUCCESS, my_session.test_init(0,0,0,NULL));
|
||||
ctx.set_my_session(&my_session);
|
||||
|
||||
init(ctx, merge_distinct, 3);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
ADD_ROW(fake_table, COL("r"), COL(1), COL(1));
|
||||
ADD_ROW(fake_table, COL("r"), COL(1), COL(2));
|
||||
ADD_ROW(fake_table, COL("s"), COL(2), COL(3));
|
||||
@ -159,16 +151,16 @@ TEST_F(TestMergeDistinctTest, test_utf8mb4_general_ci)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = get_fake_table();
|
||||
ObFakeTable& result_table = get_result_table();
|
||||
ObFakeTable &fake_table = get_fake_table();
|
||||
ObFakeTable &result_table = get_result_table();
|
||||
TestMergeDistinct merge_distinct;
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
ObSQLSessionInfo my_session;
|
||||
ASSERT_EQ(OB_SUCCESS, my_session.test_init(0, 0, 0, NULL));
|
||||
ASSERT_EQ(OB_SUCCESS, my_session.test_init(0,0,0,NULL));
|
||||
ctx.set_my_session(&my_session);
|
||||
|
||||
init(ctx, merge_distinct, 3);
|
||||
// fake table: distinct column(c1)
|
||||
//fake table: distinct column(c1)
|
||||
ADD_ROW(fake_table, COL("r"), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL("r"), COL("r"), COL(2));
|
||||
ADD_ROW(fake_table, COL("s"), COL("s"), COL(3));
|
||||
@ -355,11 +347,11 @@ TEST_F(TestMergeDistinctTest, test_invalid_argument)
|
||||
}
|
||||
*/
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_global_memory_pool();
|
||||
init_sql_factories();
|
||||
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
::testing::InitGoogleTest(&argc,argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
@ -11,42 +11,48 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#define private public
|
||||
#define protected public
|
||||
#include "sql/ob_sql_init.h"
|
||||
#include "sql/engine/aggregate/ob_merge_groupby.h"
|
||||
#include "sql/engine/aggregate/ob_aggregate_test_utils.h"
|
||||
#include "storage/blocksstable/ob_data_file_prepare.h"
|
||||
#include "share/ob_simple_mem_limit_getter.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
using namespace oceanbase::blocksstable;
|
||||
static ObSimpleMemLimitGetter getter;
|
||||
|
||||
class ObMergeGroupbyTest : public TestDataFilePrepare {
|
||||
class ObMergeGroupbyTest: public TestDataFilePrepare
|
||||
{
|
||||
public:
|
||||
ObMergeGroupbyTest();
|
||||
virtual ~ObMergeGroupbyTest();
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
private:
|
||||
// disallow copy
|
||||
ObMergeGroupbyTest(const ObMergeGroupbyTest& other);
|
||||
ObMergeGroupbyTest& operator=(const ObMergeGroupbyTest& other);
|
||||
|
||||
ObMergeGroupbyTest(const ObMergeGroupbyTest &other);
|
||||
ObMergeGroupbyTest& operator=(const ObMergeGroupbyTest &other);
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
|
||||
ObMergeGroupbyTest::ObMergeGroupbyTest() : TestDataFilePrepare("TestDisk_mergegroupby", 2 << 20, 5000)
|
||||
{}
|
||||
ObMergeGroupbyTest::ObMergeGroupbyTest() : TestDataFilePrepare(&getter,
|
||||
"TestDisk_mergegroupby", 2<<20, 5000)
|
||||
{
|
||||
}
|
||||
|
||||
ObMergeGroupbyTest::~ObMergeGroupbyTest()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void ObMergeGroupbyTest::SetUp()
|
||||
{
|
||||
TestDataFilePrepare::SetUp();
|
||||
int ret = ObTmpFileManager::get_instance().init();
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
}
|
||||
|
||||
void ObMergeGroupbyTest::TearDown()
|
||||
@ -54,20 +60,19 @@ void ObMergeGroupbyTest::TearDown()
|
||||
ObTmpFileManager::get_instance().destroy();
|
||||
TestDataFilePrepare::TearDown();
|
||||
}
|
||||
class TestMergeGroupBy : public ObMergeGroupBy {
|
||||
class TestMergeGroupBy : public ObMergeGroupBy
|
||||
{
|
||||
public:
|
||||
TestMergeGroupBy() : ObMergeGroupBy(alloc_)
|
||||
{}
|
||||
~TestMergeGroupBy()
|
||||
{}
|
||||
TestMergeGroupBy() : ObMergeGroupBy(alloc_) {}
|
||||
~TestMergeGroupBy() {}
|
||||
};
|
||||
|
||||
TEST_F(ObMergeGroupbyTest, test_utf8mb4_bin_agg)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestMergeGroupBy merge_groupby;
|
||||
bool is_distinct = false;
|
||||
bool is_number = false;
|
||||
@ -76,7 +81,7 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_bin_agg)
|
||||
ObCollationType group_cs_type = CS_TYPE_INVALID;
|
||||
|
||||
TestAggregateFactory::init(ctx, merge_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(1));
|
||||
@ -89,7 +94,8 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_bin_agg)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL("ß"), COL("r"));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, merge_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby, col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby,
|
||||
col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, merge_groupby);
|
||||
}
|
||||
|
||||
@ -97,8 +103,8 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_genaral_ci_agg)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestMergeGroupBy merge_groupby;
|
||||
bool is_distinct = false;
|
||||
bool is_number = false;
|
||||
@ -107,7 +113,7 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_genaral_ci_agg)
|
||||
ObCollationType group_cs_type = CS_TYPE_INVALID;
|
||||
|
||||
TestAggregateFactory::init(ctx, merge_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(1));
|
||||
@ -120,7 +126,8 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_genaral_ci_agg)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL("t"), COL("r"));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, merge_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby, col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby,
|
||||
col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, merge_groupby);
|
||||
}
|
||||
|
||||
@ -128,8 +135,8 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_genaral_ci_group)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestMergeGroupBy merge_groupby;
|
||||
bool is_distinct = false;
|
||||
bool is_number = true;
|
||||
@ -138,7 +145,7 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_genaral_ci_group)
|
||||
ObCollationType group_cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
|
||||
TestAggregateFactory::init(ctx, merge_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL(2), COL("ß"));
|
||||
ADD_ROW(fake_table, COL(2), COL(4), COL("s"));
|
||||
ADD_ROW(fake_table, COL(3), COL(6), COL("ß"));
|
||||
@ -146,7 +153,8 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_genaral_ci_group)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL(8), COL(2), COL(20.0), COL(5.0));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, merge_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby, col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby,
|
||||
col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, merge_groupby);
|
||||
}
|
||||
|
||||
@ -154,8 +162,8 @@ TEST_F(ObMergeGroupbyTest, test_gutf8mb4_bin_agg_distinct)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestMergeGroupBy merge_groupby;
|
||||
bool is_distinct = true;
|
||||
bool is_number = false;
|
||||
@ -164,7 +172,7 @@ TEST_F(ObMergeGroupbyTest, test_gutf8mb4_bin_agg_distinct)
|
||||
ObCollationType group_cs_type = CS_TYPE_INVALID;
|
||||
|
||||
TestAggregateFactory::init(ctx, merge_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(1));
|
||||
@ -177,7 +185,8 @@ TEST_F(ObMergeGroupbyTest, test_gutf8mb4_bin_agg_distinct)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL("ß"), COL("r"), COL(4));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, merge_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby, col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby,
|
||||
col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, merge_groupby);
|
||||
}
|
||||
|
||||
@ -185,8 +194,8 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_genaral_ci_agg_distinct)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestMergeGroupBy merge_groupby;
|
||||
bool is_distinct = true;
|
||||
bool is_number = false;
|
||||
@ -195,7 +204,7 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_genaral_ci_agg_distinct)
|
||||
ObCollationType group_cs_type = CS_TYPE_INVALID;
|
||||
|
||||
TestAggregateFactory::init(ctx, merge_groupby, col_count, is_distinct, is_number, agg_cs_type, group_cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(1));
|
||||
@ -208,21 +217,23 @@ TEST_F(ObMergeGroupbyTest, test_utf8mb4_genaral_ci_agg_distinct)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(3), COL("t"), COL("r"), COL(3));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, merge_groupby);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby, col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, merge_groupby,
|
||||
col_count, merge_groupby.get_column_count(), agg_cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, merge_groupby);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(ObMergeGroupbyTest, test_groupby_without_distinct)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestMergeGroupBy merge_groupby;
|
||||
ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
|
||||
TestAggregateFactory::init(ctx, merge_groupby, 3, false);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL(1), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL(2), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL(2), COL(1));
|
||||
@ -244,13 +255,13 @@ TEST_F(ObMergeGroupbyTest, test_groupby_without_distinct1)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestMergeGroupBy merge_groupby;
|
||||
ObCollationType agg_cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
|
||||
TestAggregateFactory::init(ctx, merge_groupby, 3, false);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL(3), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL(null), COL(2));
|
||||
ADD_ROW(fake_table, COL(3), COL(null), COL(2));
|
||||
@ -393,11 +404,11 @@ TEST_F(ObMergeGroupbyTest, test_invalid_argument1)
|
||||
}
|
||||
*/
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_global_memory_pool();
|
||||
init_sql_factories();
|
||||
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
::testing::InitGoogleTest(&argc,argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
@ -11,42 +11,48 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#define private public
|
||||
#define protected public
|
||||
#include "sql/ob_sql_init.h"
|
||||
#include "sql/engine/aggregate/ob_scalar_aggregate.h"
|
||||
#include "sql/engine/aggregate/ob_aggregate_test_utils.h"
|
||||
#include "sql/engine/test_engine_util.h"
|
||||
#include "storage/blocksstable/ob_data_file_prepare.h"
|
||||
#include "share/ob_simple_mem_limit_getter.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
using namespace oceanbase::blocksstable;
|
||||
static ObSimpleMemLimitGetter getter;
|
||||
|
||||
class TestScalarAggregateTest : public TestDataFilePrepare {
|
||||
class TestScalarAggregateTest: public TestDataFilePrepare
|
||||
{
|
||||
public:
|
||||
TestScalarAggregateTest();
|
||||
virtual ~TestScalarAggregateTest();
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
private:
|
||||
// disallow copy
|
||||
TestScalarAggregateTest(const TestScalarAggregateTest& other);
|
||||
TestScalarAggregateTest& operator=(const TestScalarAggregateTest& other);
|
||||
|
||||
TestScalarAggregateTest(const TestScalarAggregateTest &other);
|
||||
TestScalarAggregateTest& operator=(const TestScalarAggregateTest &other);
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
TestScalarAggregateTest::TestScalarAggregateTest() : TestDataFilePrepare("TestDisk_scalar_groupby", 2 << 20, 5000)
|
||||
{}
|
||||
TestScalarAggregateTest::TestScalarAggregateTest() : TestDataFilePrepare(&getter,
|
||||
"TestDisk_scalar_groupby", 2<<20, 5000)
|
||||
{
|
||||
}
|
||||
|
||||
TestScalarAggregateTest::~TestScalarAggregateTest()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void TestScalarAggregateTest::SetUp()
|
||||
{
|
||||
TestDataFilePrepare::SetUp();
|
||||
int ret = ObTmpFileManager::get_instance().init();
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
}
|
||||
|
||||
void TestScalarAggregateTest::TearDown()
|
||||
@ -55,12 +61,11 @@ void TestScalarAggregateTest::TearDown()
|
||||
TestDataFilePrepare::TearDown();
|
||||
}
|
||||
|
||||
class TestScalarAggregate : public ObScalarAggregate {
|
||||
class TestScalarAggregate : public ObScalarAggregate
|
||||
{
|
||||
public:
|
||||
TestScalarAggregate() : ObScalarAggregate(alloc_)
|
||||
{}
|
||||
~TestScalarAggregate()
|
||||
{}
|
||||
TestScalarAggregate() :ObScalarAggregate(alloc_) {}
|
||||
~TestScalarAggregate() {}
|
||||
};
|
||||
|
||||
TEST_F(TestScalarAggregateTest, test_utf8mb4_bin)
|
||||
@ -68,8 +73,8 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_bin)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
int64_t col_count = 3;
|
||||
bool is_distinct = false;
|
||||
@ -77,7 +82,7 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_bin)
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_BIN;
|
||||
|
||||
TestAggregateFactory::init(ctx, scalar_aggr_op, col_count, is_distinct, is_number, cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(2));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(3));
|
||||
@ -85,7 +90,8 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_bin)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL("ß"), COL("r"), COL(4));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, scalar_aggr_op);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, scalar_aggr_op, col_count, scalar_aggr_op.get_column_count(), cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, scalar_aggr_op,
|
||||
col_count, scalar_aggr_op.get_column_count(), cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, scalar_aggr_op);
|
||||
}
|
||||
|
||||
@ -94,8 +100,8 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_genaral_ci)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
int64_t col_count = 3;
|
||||
bool is_distinct = false;
|
||||
@ -103,7 +109,7 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_genaral_ci)
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
|
||||
TestAggregateFactory::init(ctx, scalar_aggr_op, col_count, is_distinct, is_number, cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(2));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(3));
|
||||
@ -111,7 +117,8 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_genaral_ci)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL("t"), COL("r"), COL(3));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, scalar_aggr_op);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, scalar_aggr_op, col_count, scalar_aggr_op.get_column_count(), cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, scalar_aggr_op,
|
||||
col_count, scalar_aggr_op.get_column_count(), cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, scalar_aggr_op);
|
||||
}
|
||||
|
||||
@ -120,8 +127,8 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_bin_distinct)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
int64_t col_count = 3;
|
||||
bool is_distinct = true;
|
||||
@ -129,7 +136,7 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_bin_distinct)
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_BIN;
|
||||
|
||||
TestAggregateFactory::init(ctx, scalar_aggr_op, col_count, is_distinct, is_number, cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(2));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(3));
|
||||
@ -141,7 +148,8 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_bin_distinct)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(4), COL("ß"), COL("r"), COL(4));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, scalar_aggr_op);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, scalar_aggr_op, col_count, scalar_aggr_op.get_column_count(), cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, scalar_aggr_op,
|
||||
col_count, scalar_aggr_op.get_column_count(), cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, scalar_aggr_op);
|
||||
}
|
||||
|
||||
@ -150,8 +158,8 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_genaral_ci_distinct)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
int64_t col_count = 3;
|
||||
bool is_distinct = true;
|
||||
@ -159,7 +167,7 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_genaral_ci_distinct)
|
||||
ObCollationType cs_type = CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
|
||||
TestAggregateFactory::init(ctx, scalar_aggr_op, col_count, is_distinct, is_number, cs_type);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL("r"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("s"), COL(2));
|
||||
ADD_ROW(fake_table, COL(3), COL("t"), COL(3));
|
||||
@ -171,7 +179,8 @@ TEST_F(TestScalarAggregateTest, test_utf8mb4_genaral_ci_distinct)
|
||||
ADD_ROW(result_table, COL(0), COL(0), COL(0), COL(3), COL("t"), COL("r"), COL(3));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, scalar_aggr_op);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, scalar_aggr_op, col_count, scalar_aggr_op.get_column_count(), cs_type);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, scalar_aggr_op,
|
||||
col_count, scalar_aggr_op.get_column_count(), cs_type);
|
||||
TestAggregateFactory::close_operator(ctx, scalar_aggr_op);
|
||||
}
|
||||
|
||||
@ -180,12 +189,12 @@ TEST_F(TestScalarAggregateTest, test_aggr_without_distinct)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
|
||||
TestAggregateFactory::init(ctx, scalar_aggr_op, 3, false);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL(1), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL(2), COL(2));
|
||||
ADD_ROW(fake_table, COL(5), COL(2), COL(3));
|
||||
@ -207,12 +216,12 @@ TEST_F(TestScalarAggregateTest, test_aggr_with_distinct)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
|
||||
TestAggregateFactory::init(ctx, scalar_aggr_op, 3, true);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(fake_table, COL(1), COL(1), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL(1), COL(1));
|
||||
ADD_ROW(fake_table, COL(3), COL(2), COL(1));
|
||||
@ -234,22 +243,12 @@ TEST_F(TestScalarAggregateTest, test_aggr_empty_set)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
|
||||
TestAggregateFactory::init(ctx, scalar_aggr_op, 3, true);
|
||||
// fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(result_table,
|
||||
COL(null),
|
||||
COL(null),
|
||||
COL(null),
|
||||
COL(0),
|
||||
COL(null),
|
||||
COL(null),
|
||||
COL(0),
|
||||
COL(null),
|
||||
COL(null),
|
||||
COL(0));
|
||||
//fake table: index_col(primary key), aggr_col, groupby_col
|
||||
ADD_ROW(result_table, COL(null), COL(null), COL(null), COL(0), COL(null), COL(null), COL(0), COL(null), COL(null), COL(0));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, scalar_aggr_op);
|
||||
EXCEPT_RESULT(ctx, result_table, scalar_aggr_op, CS_TYPE_UTF8MB4_BIN);
|
||||
@ -261,23 +260,19 @@ TEST_F(TestScalarAggregateTest, test_aggr_bug_6131507)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable& result_table = TestAggregateFactory::get_result_table();
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
ObFakeTable &result_table = TestAggregateFactory::get_result_table();
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
|
||||
TestAggregateFactory::init(ctx, scalar_aggr_op, 3);
|
||||
// fake table: c, b, a(primary key)
|
||||
//fake table: c, b, a(primary key)
|
||||
ADD_ROW(fake_table, COL(null), COL(4), COL(1));
|
||||
ADD_ROW(fake_table, COL(null), COL(3), COL(3));
|
||||
ADD_ROW(fake_table, COL(null), COL(3), COL(4));
|
||||
|
||||
ADD_ROW(result_table,
|
||||
COL(null),
|
||||
COL(4),
|
||||
COL(1),
|
||||
COL(null),
|
||||
COL(3.33333333333333333333333333333333333333333333),
|
||||
COL(2.66666666666666666666666666666666666666666667));
|
||||
ADD_ROW(result_table, COL(null), COL(4), COL(1), COL(null),
|
||||
COL(3.33333333333333333333333333333333333333333333),
|
||||
COL(2.66666666666666666666666666666666666666666667));
|
||||
|
||||
TestAggregateFactory::open_operator(ctx, scalar_aggr_op);
|
||||
EXCEPT_RESULT_WITH_IDX(ctx, result_table, scalar_aggr_op, 0, 3, CS_TYPE_UTF8MB4_BIN);
|
||||
@ -292,7 +287,7 @@ TEST_F(TestScalarAggregateTest, test_invalid_argument)
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx1));
|
||||
ObFakeTable fake_table;
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
const ObNewRow* row = NULL;
|
||||
const ObNewRow *row = NULL;
|
||||
|
||||
ASSERT_EQ(OB_NOT_INIT, scalar_aggr_op.open(ctx));
|
||||
scalar_aggr_op.reset();
|
||||
@ -317,14 +312,14 @@ TEST_F(TestScalarAggregateTest, test_invalid_argument1)
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecContext ctx;
|
||||
ASSERT_EQ(OB_SUCCESS, create_test_session(ctx));
|
||||
const ObNewRow* row = NULL;
|
||||
ObFakeTable& fake_table = TestAggregateFactory::get_fake_table();
|
||||
const ObNewRow *row = NULL;
|
||||
ObFakeTable &fake_table = TestAggregateFactory::get_fake_table();
|
||||
TestScalarAggregate scalar_aggr_op;
|
||||
ObArenaAllocator alloc;
|
||||
ObAggregateExpression col_expr(alloc);
|
||||
|
||||
TestAggregateFactory::init(ctx, scalar_aggr_op, 3, false);
|
||||
// prepare rows, equal in the first row
|
||||
//prepare rows, equal in the first row
|
||||
ADD_ROW(fake_table, COL(1), COL("123"), COL(1));
|
||||
ADD_ROW(fake_table, COL(2), COL("456"), COL(1));
|
||||
|
||||
@ -332,7 +327,7 @@ TEST_F(TestScalarAggregateTest, test_invalid_argument1)
|
||||
ASSERT_EQ(OB_SUCCESS, scalar_aggr_op.open(ctx));
|
||||
ASSERT_EQ(OB_EXCEED_MEM_LIMIT, scalar_aggr_op.get_next_row(ctx, row));
|
||||
scalar_aggr_op.reset();
|
||||
// ASSERT_EQ(OB_NOT_INIT, scalar_aggr_op.add_aggr_column(&col_expr));
|
||||
//ASSERT_EQ(OB_NOT_INIT, scalar_aggr_op.add_aggr_column(&col_expr));
|
||||
}
|
||||
|
||||
TEST_F(TestScalarAggregateTest, test_serialize_and_deserialize)
|
||||
@ -357,11 +352,11 @@ TEST_F(TestScalarAggregateTest, test_serialize_and_deserialize)
|
||||
ASSERT_EQ(0, strcmp(to_cstring(scalar_aggr_op), to_cstring(deserialize_op)));
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
init_global_memory_pool();
|
||||
init_sql_factories();
|
||||
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
::testing::InitGoogleTest(&argc,argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
Reference in New Issue
Block a user