Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deps/oblib/src/lib/ob_name_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1258,5 +1258,6 @@
#define N_AI_EMBED "ai_embed"
#define N_AI_RERANK "ai_rerank"
#define N_AI_PROMPT "ai_prompt"
#define N_AI_SPLIT_DOCUMENT "ai_split_document"
#define N_CHECK_LOCATION_ACCESS "check_location_access"
#endif //OCEANBASE_LIB_OB_NAME_DEF_H_
2 changes: 2 additions & 0 deletions src/objit/include/objit/common/ob_item_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,8 @@ typedef enum ObItemType
T_FUN_SYS_AI_RERANK = 2084,
T_FUN_MD5_CNN_WS = 2085,
T_FUN_SYS_BUCKET = 2086,
T_FUN_SYS_LOAD_FILE = 2087,
T_FUN_SYS_AI_SPLIT_DOCUMENT = 2088,
T_MAX_OP = 3000,

//pseudo column, to mark the group iterator id
Expand Down
2 changes: 2 additions & 0 deletions src/sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ ob_set_subtarget(ob_sql engine_expr
engine/expr/ob_batch_eval_util.cpp
engine/expr/ob_expr.cpp
engine/expr/ob_expr_acos.cpp
engine/expr/ob_expr_load_file.cpp
engine/expr/ob_expr_ai/ob_expr_ai_split_document.cpp
engine/expr/ob_expr_symmetric_encrypt.cpp
engine/expr/ob_expr_agg_param_list.cpp
engine/expr/ob_expr_and.cpp
Expand Down
36 changes: 35 additions & 1 deletion src/sql/engine/basic/ob_function_table_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "sql/engine/basic/ob_function_table_op.h"
#include "sql/engine/ob_exec_context.h"
#include "sql/engine/expr/ob_expr_lob_utils.h"
#include "sql/engine/expr/ob_expr_ai/ob_expr_ai_split_document.h"


namespace oceanbase
Expand Down Expand Up @@ -232,6 +233,13 @@ int ObFunctionTableOp::inner_get_next_row_sys_func()
ObPhysicalPlanCtx *plan_ctx = nullptr;
ObDatum *value = nullptr;
clear_evaluated_flag();
// value_expr_ drives the rt_ctx (one chunk per eval) but is NOT in this op's
// eval_infos_, so clear_evaluated_flag() above does not reset it. Without this
// the framework returns the cached first-chunk datum on every row -> infinite
// rows. Force re-eval so eval_func_ advances the rt_ctx each call.
if (OB_NOT_NULL(MY_SPEC.value_expr_)) {
MY_SPEC.value_expr_->get_eval_info(eval_ctx_).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));
Expand All @@ -241,9 +249,35 @@ int ObFunctionTableOp::inner_get_next_row_sys_func()
if (OB_ITER_END != ret) {
LOG_WARN("failed to eval value expr", K(ret));
}
} else {
} else if (MY_SPEC.column_exprs_.count() <= 1) {
// GENERATOR / single-column path (unchanged)
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_);
} else if (T_FUN_SYS_AI_SPLIT_DOCUMENT == MY_SPEC.value_expr_->type_) {
// AI_SPLIT_DOCUMENT multi-column path: eval advanced the rt_ctx; read 4 values.
// Guard on item type, not just count(): count()>1 alone is unsafe if a future
// multi-column sys_func table function is added (would mis-cast the rt_ctx).
ObExprAISplitDocumentCtx *split_ctx = static_cast<ObExprAISplitDocumentCtx *>(
ctx_.get_expr_op_ctx(MY_SPEC.value_expr_->expr_ctx_id_));
if (OB_ISNULL(split_ctx)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("ai_split_document: rt_ctx is null after eval", K(ret));
} else {
// locate_datum_for_write/set_int/set_string do not fail; nothing to propagate.
auto set_int = [&](int64_t idx, int64_t v) {
MY_SPEC.column_exprs_.at(idx)->locate_datum_for_write(eval_ctx_).set_int(v);
MY_SPEC.column_exprs_.at(idx)->set_evaluated_projected(eval_ctx_);
};
set_int(0, split_ctx->curr_chunk_id_);
set_int(1, split_ctx->curr_chunk_offset_);
set_int(2, split_ctx->curr_chunk_length_);
MY_SPEC.column_exprs_.at(3)->locate_datum_for_write(eval_ctx_).set_string(split_ctx->curr_chunk_text_);
MY_SPEC.column_exprs_.at(3)->set_evaluated_projected(eval_ctx_);
}
} else {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unsupported multi-column sys_func table function", K(ret),
K(MY_SPEC.value_expr_->type_), K(MY_SPEC.column_exprs_.count()));
}
return ret;
}
Expand Down
Loading
Loading