11#include " function/query_fts_bind_data.h"
22
3+ #include " binder/binder.h"
34#include " binder/expression/expression_util.h"
45#include " catalog/fts_index_catalog_entry.h"
56#include " common/exception/binder.h"
67#include " common/string_utils.h"
7- #include " function/stem.h"
88#include " libstemmer.h"
99#include " re2.h"
1010#include " storage/storage_manager.h"
@@ -18,17 +18,29 @@ using namespace kuzu::common;
1818using namespace kuzu ::binder;
1919using namespace kuzu ::storage;
2020
21- QueryFTSOptionalParams::QueryFTSOptionalParams (const binder::expression_vector& optionalParams) {
21+ static std::shared_ptr<Expression> applyImplicitCastingIfNecessary (main::ClientContext* context,
22+ std::shared_ptr<Expression> expr, LogicalType targetType) {
23+ if (expr->getDataType () != targetType) {
24+ Binder binder{context};
25+ expr = binder.getExpressionBinder ()->implicitCastIfNecessary (expr, targetType);
26+ expr = binder.getExpressionBinder ()->foldExpression (expr);
27+ }
28+ return expr;
29+ }
30+
31+ QueryFTSOptionalParams::QueryFTSOptionalParams (main::ClientContext* context,
32+ const binder::expression_vector& optionalParams) {
2233 for (auto & optionalParam : optionalParams) {
2334 auto paramName = StringUtils::getLower (optionalParam->getAlias ());
2435 if (paramName == K::NAME ) {
25- k = optionalParam;
36+ k = applyImplicitCastingIfNecessary (context, optionalParam, LogicalType{K:: TYPE }) ;
2637 } else if (paramName == B::NAME ) {
27- b = optionalParam;
38+ b = applyImplicitCastingIfNecessary (context, optionalParam, LogicalType{B:: TYPE }) ;
2839 } else if (paramName == Conjunctive::NAME ) {
29- conjunctive = optionalParam;
40+ conjunctive = applyImplicitCastingIfNecessary (context, optionalParam,
41+ LogicalType{Conjunctive::TYPE });
3042 } else if (paramName == TopK::NAME ) {
31- topK = optionalParam;
43+ topK = applyImplicitCastingIfNecessary (context, optionalParam, LogicalType{TopK:: TYPE }) ;
3244 } else {
3345 throw common::BinderException{" Unknown optional parameter: " + paramName};
3446 }
0 commit comments