summaryrefslogtreecommitdiffstats
path: root/yql/essentials/ast/yql_expr.cpp
diff options
context:
space:
mode:
authorvityaman <[email protected]>2025-04-14 20:03:33 +0300
committerrobot-piglet <[email protected]>2025-04-14 20:47:32 +0300
commitb147484e3469f7dd312ffbc18997c2cc3fae5be4 (patch)
treef59e3d0cd29cbfefbfa888c3f3bb72acf0fe3f0d /yql/essentials/ast/yql_expr.cpp
parenta0027051fda6c52db7166202317ee37ebc451d3a (diff)
YQL-19747 Extract NormalizeName from yql/.../core/ast
We need the `NYql::NormalizeName` at `yql/.../sql/v1/complete`, but do not want to depend on the entire `yql/.../core/ast` module, so moving it to `yql/.../core/sql_types` module. We need it to find equivalent names for a proper candidates ranking as `MULTI_AGGREGATE_BY` and `MultiAggregateBy` are equivalent and their frequencies should be merged. Also we can apply this function to `NameRequest::prefix` and suggest `MULTI_AGGREGATE_BY` on `prefix.StartsWith("multia")`. - Related to https://github.com/ydb-platform/ydb/issues/9056 - Related to https://github.com/vityaman/ydb/issues/21 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1204 commit_hash:02f3ef316bbca818e22aafe88edfde8e4eb214c3
Diffstat (limited to 'yql/essentials/ast/yql_expr.cpp')
-rw-r--r--yql/essentials/ast/yql_expr.cpp54
1 files changed, 0 insertions, 54 deletions
diff --git a/yql/essentials/ast/yql_expr.cpp b/yql/essentials/ast/yql_expr.cpp
index 21d0b9a446c..fb60a08476b 100644
--- a/yql/essentials/ast/yql_expr.cpp
+++ b/yql/essentials/ast/yql_expr.cpp
@@ -3830,60 +3830,6 @@ const TTypeAnnotationNode& RemoveOptionality(const TTypeAnnotationNode& type) {
return ETypeAnnotationKind::Optional == type.GetKind() ? *type.Cast<TOptionalExprType>()->GetItemType() : type;
}
-TMaybe<TIssue> NormalizeName(TPosition position, TString& name) {
- const ui32 inputLength = name.length();
- ui32 startCharPos = 0;
- ui32 totalSkipped = 0;
- bool atStart = true;
- bool justSkippedUnderscore = false;
- for (ui32 i = 0; i < inputLength; ++i) {
- const char c = name.at(i);
- if (c == '_') {
- if (!atStart) {
- if (justSkippedUnderscore) {
- return TIssue(position, TStringBuilder() << "\"" << name << "\" looks weird, has multiple consecutive underscores");
- }
- justSkippedUnderscore = true;
- ++totalSkipped;
- continue;
- } else {
- ++startCharPos;
- }
- }
- else {
- atStart = false;
- justSkippedUnderscore = false;
- }
- }
-
- if (totalSkipped >= 5) {
- return TIssue(position, TStringBuilder() << "\"" << name << "\" looks weird, has multiple consecutive underscores");
- }
-
- ui32 outPos = startCharPos;
- for (ui32 i = startCharPos; i < inputLength; i++) {
- const char c = name.at(i);
- if (c == '_') {
- continue;
- } else {
- name[outPos] = AsciiToLower(c);
- ++outPos;
- }
- }
-
- name.resize(outPos);
- Y_ABORT_UNLESS(inputLength - outPos == totalSkipped);
-
- return Nothing();
-}
-
-TString NormalizeName(const TStringBuf& name) {
- TString result(name);
- TMaybe<TIssue> error = NormalizeName(TPosition(), result);
- YQL_ENSURE(error.Empty(), "" << error->GetMessage());
- return result;
-}
-
void TDefaultTypeAnnotationVisitor::Visit(const TUnitExprType& type) {
Y_UNUSED(type);
}