Skip to content

Commit

Permalink
revise log infos
Browse files Browse the repository at this point in the history
Signed-off-by: SevenJ <[email protected]>
  • Loading branch information
Wenjun7J committed Feb 6, 2025
1 parent 4656202 commit 98d2fc0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
17 changes: 8 additions & 9 deletions be/src/exprs/string_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct ConcatState {
std::string tail;
};

template<LogicalType T>
template <LogicalType T>
struct FieldFuncState {
bool all_const = false;
bool list_all_const = false;
Expand Down Expand Up @@ -581,9 +581,9 @@ class StringFunctions {
DEFINE_VECTORIZED_FN(ngram_search_case_insensitive);

DEFINE_VECTORIZED_FN_TEMPLATE(field);
template <LogicalType Type>
template <LogicalType Type>
static Status field_prepare(FunctionContext* context, FunctionContext::FunctionStateScope scope);
template <LogicalType Type>
template <LogicalType Type>
static Status field_close(FunctionContext* context, FunctionContext::FunctionStateScope scope);

static Status ngram_search_prepare(FunctionContext* context, FunctionContext::FunctionStateScope scope);
Expand Down Expand Up @@ -695,7 +695,7 @@ StatusOr<ColumnPtr> StringFunctions::money_format_decimal(FunctionContext* conte
return result.build(ColumnHelper::is_all_const(columns));
}

template <LogicalType Type>
template <LogicalType Type>
Status StringFunctions::field_prepare(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
if (scope != FunctionContext::FRAGMENT_LOCAL) {
return Status::OK();
Expand Down Expand Up @@ -729,7 +729,7 @@ Status StringFunctions::field_prepare(FunctionContext* context, FunctionContext:
return Status::OK();
}

template <LogicalType Type>
template <LogicalType Type>
Status StringFunctions::field_close(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
if (scope != FunctionContext::FRAGMENT_LOCAL) {
return Status::OK();
Expand All @@ -751,15 +751,14 @@ StatusOr<ColumnPtr> StringFunctions::field(FunctionContext* context, const Colum
result.append(0);
return result.build(true);
} else if (state != nullptr) {
LOG(WARNING) << "state:" << state->all_const << " " << state->list_all_const << std::endl;
if (state->all_const) {
const auto list_col = context->get_constant_column(0);
const auto list_val = ColumnHelper::get_const_value<Type>(list_col);
auto it = state->mp.find(list_val);
if (it != state->mp.end()) {
result.append(it->second);
result.append(it->second);
} else {
result.append(0);
result.append(0);
}
return result.build(true);
} else if (state->list_all_const) {
Expand Down Expand Up @@ -791,7 +790,7 @@ StatusOr<ColumnPtr> StringFunctions::field(FunctionContext* context, const Colum
res = id;
break;
}
id ++;
id++;
}

result.append(res);
Expand Down
6 changes: 5 additions & 1 deletion be/test/exprs/string_fn_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3998,7 +3998,11 @@ PARALLEL_TEST(VecStringFunctionsTest, fieldIntTest) {
columns.emplace_back(param1);
columns.emplace_back(param2);
columns.emplace_back(param3);
int res[] = {0, 1, 2, 0 , 0};
int res[] = {0, 1, 2, 0, 0};
FieldFuncState<TYPE_INT> func_state;
ctx->set_function_state(FunctionContext::FRAGMENT_LOCAL, &func_state);
func_state.all_const = false;
func_state.list_all_const = false;
ColumnPtr result = StringFunctions::field<TYPE_INT>(ctx.get(), columns).value();

ASSERT_TRUE(result->is_numeric());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ private static Function getAdjustedAnalyzedFunction(ConnectContext session,
(targetType.isStringType() && argumentTypes[i].isStringType())) {
targetType = Type.getAssignmentCompatibleType(targetType, argumentTypes[i], false);
if (targetType.isInvalid()) {
throw new SemanticException("Parameter's type is not invalid");
throw new SemanticException("Parameter's type is invalid");
}
} else {
targetType = Type.DOUBLE;
Expand Down

0 comments on commit 98d2fc0

Please sign in to comment.