Skip to content

Commit 99e50ba

Browse files
Copilotkungasc
andcommitted
Add type annotation for FulltextAnalyze callable
Co-authored-by: kunga <6822967+kunga@users.noreply.github.com>
1 parent aecb95b commit 99e50ba

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

ydb/core/kqp/opt/kqp_type_ann.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,54 @@ TStatus AnnotateKqpEnsure(const TExprNode::TPtr& node, TExprContext& ctx) {
17601760
return TStatus::Ok;
17611761
}
17621762

1763+
TStatus AnnotateFulltextAnalyze(const TExprNode::TPtr& node, TExprContext& ctx) {
1764+
if (!EnsureArgsCount(*node, 2, ctx)) {
1765+
return TStatus::Error;
1766+
}
1767+
1768+
// First argument: text (should be String or Utf8)
1769+
const auto* textArg = node->Child(0);
1770+
if (!EnsureComputable(*textArg, ctx)) {
1771+
return TStatus::Error;
1772+
}
1773+
1774+
const TDataExprType* textDataType;
1775+
bool isOptional;
1776+
if (!EnsureDataOrOptionalOfData(*textArg, isOptional, textDataType, ctx)) {
1777+
return TStatus::Error;
1778+
}
1779+
1780+
if (textDataType->GetSlot() != EDataSlot::String && textDataType->GetSlot() != EDataSlot::Utf8) {
1781+
ctx.AddError(TIssue(ctx.GetPosition(textArg->Pos()), TStringBuilder()
1782+
<< "Expected String or Utf8 for text argument, but got: " << *textArg->GetTypeAnn()));
1783+
return TStatus::Error;
1784+
}
1785+
1786+
// Second argument: settings (should be String - serialized proto)
1787+
const auto* settingsArg = node->Child(1);
1788+
if (!EnsureComputable(*settingsArg, ctx)) {
1789+
return TStatus::Error;
1790+
}
1791+
1792+
const TDataExprType* settingsDataType;
1793+
if (!EnsureDataOrOptionalOfData(*settingsArg, isOptional, settingsDataType, ctx)) {
1794+
return TStatus::Error;
1795+
}
1796+
1797+
if (settingsDataType->GetSlot() != EDataSlot::String) {
1798+
ctx.AddError(TIssue(ctx.GetPosition(settingsArg->Pos()), TStringBuilder()
1799+
<< "Expected String for settings argument, but got: " << *settingsArg->GetTypeAnn()));
1800+
return TStatus::Error;
1801+
}
1802+
1803+
// Return type: List<String>
1804+
auto stringType = ctx.MakeType<TDataExprType>(EDataSlot::String);
1805+
auto listType = ctx.MakeType<TListExprType>(stringType);
1806+
node->SetTypeAnn(listType);
1807+
1808+
return TStatus::Ok;
1809+
}
1810+
17631811
TStatus AnnotateSequencerConnection(const TExprNode::TPtr& node, TExprContext& ctx, const TString& cluster,
17641812
const TKikimrTablesData& tablesData, bool withSystemColumns)
17651813
{
@@ -2564,6 +2612,10 @@ TAutoPtr<IGraphTransformer> CreateKqpTypeAnnotationTransformer(const TString& cl
25642612
return AnnotateKqpEnsure(input, ctx);
25652613
}
25662614

2615+
if (TFulltextAnalyze::Match(input.Get())) {
2616+
return AnnotateFulltextAnalyze(input, ctx);
2617+
}
2618+
25672619
if (TKqpReadRangesSourceSettings::Match(input.Get())) {
25682620
return AnnotateKqpSourceSettings(input, ctx, cluster, *tablesData, config->SystemColumnsEnabled());
25692621
}

0 commit comments

Comments
 (0)