[FEAT MERGE] [v4.2] add table generator and several random utility functions
This commit is contained in:
@ -37,6 +37,14 @@ int ObFunctionTableOp::inner_open()
|
||||
int ret = OB_SUCCESS;
|
||||
node_idx_ = 0;
|
||||
already_calc_ = false;
|
||||
if (OB_ISNULL(MY_SPEC.value_expr_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("value expr is not init", K(ret));
|
||||
} else if (ObExtendType == MY_SPEC.value_expr_->datum_meta_.type_) {
|
||||
next_row_func_ = &ObFunctionTableOp::inner_get_next_row_udf;
|
||||
} else {
|
||||
next_row_func_ = &ObFunctionTableOp::inner_get_next_row_sys_func;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -115,6 +123,11 @@ int ObFunctionTableOp::get_current_result(ObObj &result)
|
||||
}
|
||||
|
||||
int ObFunctionTableOp::inner_get_next_row()
|
||||
{
|
||||
return (this->*next_row_func_)();
|
||||
}
|
||||
|
||||
int ObFunctionTableOp::inner_get_next_row_udf()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObPhysicalPlanCtx *plan_ctx = nullptr;
|
||||
@ -205,5 +218,28 @@ int ObFunctionTableOp::inner_get_next_row()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObFunctionTableOp::inner_get_next_row_sys_func()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObPhysicalPlanCtx *plan_ctx = nullptr;
|
||||
ObDatum *value = nullptr;
|
||||
clear_evaluated_flag();
|
||||
if (OB_ISNULL(plan_ctx = ctx_.get_physical_plan_ctx())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get plan ctx", K(ret), K(plan_ctx));
|
||||
} else if (OB_FAIL(ctx_.check_status())) {
|
||||
LOG_WARN("failed to check status ", K(ret));
|
||||
} else if (OB_FAIL(MY_SPEC.value_expr_->eval(eval_ctx_, value))) {
|
||||
if (OB_ITER_END != ret) {
|
||||
LOG_WARN("failed to eval value expr", K(ret));
|
||||
}
|
||||
} else {
|
||||
MY_SPEC.column_exprs_.at(0)->locate_datum_for_write(eval_ctx_).set_datum(*value);
|
||||
MY_SPEC.column_exprs_.at(0)->set_evaluated_projected(eval_ctx_);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace sql
|
||||
} // end namespace oceanbase
|
||||
|
||||
@ -55,6 +55,8 @@ public:
|
||||
virtual int inner_close() override;
|
||||
virtual void destroy() override;
|
||||
private:
|
||||
int inner_get_next_row_udf();
|
||||
int inner_get_next_row_sys_func();
|
||||
int get_current_result(common::ObObj &result);
|
||||
int64_t node_idx_;
|
||||
bool already_calc_;
|
||||
@ -62,9 +64,10 @@ private:
|
||||
int64_t col_count_;
|
||||
common::ObObj value_;
|
||||
pl::ObPLCollection *value_table_;
|
||||
int (ObFunctionTableOp::*next_row_func_)();
|
||||
};
|
||||
|
||||
} // end namespace sql
|
||||
} // end namespace oceanbase
|
||||
|
||||
#endif /* OCEANBASE_BASIC_OB_FUNCTION_TABLE_OP_H_ */
|
||||
#endif /* OCEANBASE_BASIC_OB_FUNCTION_TABLE_OP_H_ */
|
||||
|
||||
Reference in New Issue
Block a user