summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql
diff options
context:
space:
mode:
authorvitya-smirnov <[email protected]>2025-09-29 11:00:03 +0300
committervitya-smirnov <[email protected]>2025-09-29 11:20:30 +0300
commit76daaf8d4bff79c5770bd420f418d9b393a3588e (patch)
tree7a0465afb49242c0489365dee1ed1737b38766c6 /yql/essentials/sql
parent235c58b4db5e636d2419a06b0a0195007f09dad4 (diff)
YQL-20461: Normalize table function names
So now both `AsTable` and `AS_TABLE` work. commit_hash:ae8c33f44e7b10de02a9d979373f4b0602ff0b12
Diffstat (limited to 'yql/essentials/sql')
-rw-r--r--yql/essentials/sql/v1/query.cpp18
-rw-r--r--yql/essentials/sql/v1/sql_translation.cpp10
2 files changed, 20 insertions, 8 deletions
diff --git a/yql/essentials/sql/v1/query.cpp b/yql/essentials/sql/v1/query.cpp
index 31e88abc353..75eeba34115 100644
--- a/yql/essentials/sql/v1/query.cpp
+++ b/yql/essentials/sql/v1/query.cpp
@@ -433,7 +433,13 @@ public:
return nullptr;
}
- TCiString func(Func_);
+ TString func = Func_;
+ if (auto issue = NormalizeName(Pos_, func)) {
+ ctx.Error(Pos_) << issue->GetMessage();
+ ctx.IncrementMonCounter("sql_errors", "NormalizeTableFunctionError");
+ return nullptr;
+ }
+
if (func != "object" && func != "walkfolders") {
for (auto& arg: Args_) {
if (arg.Expr->GetLabel()) {
@@ -442,7 +448,7 @@ public:
}
}
}
- if (func == "concat_strict") {
+ if (func == "concatstrict") {
auto tuple = Y();
for (auto& arg: Args_) {
ExtractTableName(ctx, arg);
@@ -492,8 +498,8 @@ public:
return concat;
}
- else if (func == "range" || func == "range_strict" || func == "like" || func == "like_strict" ||
- func == "regexp" || func == "regexp_strict" || func == "filter" || func == "filter_strict") {
+ else if (func == "range" || func == "rangestrict" || func == "like" || func == "likestrict" ||
+ func == "regexp" || func == "regexpstrict" || func == "filter" || func == "filterstrict") {
bool isRange = func.StartsWith("range");
bool isFilter = func.StartsWith("filter");
size_t minArgs = isRange ? 1 : 2;
@@ -539,7 +545,7 @@ public:
if (!path) {
return nullptr;
}
- auto range = Y(func.EndsWith("_strict") ? "MrTableRangeStrict" : "MrTableRange", path);
+ auto range = Y(func.EndsWith("strict") ? "MrTableRangeStrict" : "MrTableRange", path);
TNodePtr predicate;
TDeferredAtom suffix;
if (func.StartsWith("range")) {
@@ -618,7 +624,7 @@ public:
}
return key;
- } else if (func == "each" || func == "each_strict") {
+ } else if (func == "each" || func == "eachstrict") {
auto each = Y(func == "each" ? "MrTableEach" : "MrTableEachStrict");
for (auto& arg : Args_) {
if (arg.HasAt) {
diff --git a/yql/essentials/sql/v1/sql_translation.cpp b/yql/essentials/sql/v1/sql_translation.cpp
index 8f24599cfae..40d7a88776b 100644
--- a/yql/essentials/sql/v1/sql_translation.cpp
+++ b/yql/essentials/sql/v1/sql_translation.cpp
@@ -1459,9 +1459,15 @@ TMaybe<TSourcePtr> TSqlTranslation::AsTableImpl(const TRule_table_ref& node) {
if (block.Alt_case() == TRule_table_ref::TBlock3::kAlt2) {
auto& alt = block.GetAlt2();
- TCiString func(Id(alt.GetRule_an_id_expr1(), *this));
- if (func == "as_table") {
+ TString func = Id(alt.GetRule_an_id_expr1(), *this);
+ if (auto issue = NormalizeName(Ctx_.Pos(), func)) {
+ Error() << issue->GetMessage();
+ Ctx_.IncrementMonCounter("sql_errors", "NormalizeTableFunctionError");
+ return nullptr;
+ }
+
+ if (func == "astable") {
if (node.HasBlock1()) {
Ctx_.Error() << "Cluster shouldn't be specified for AS_TABLE source";
return TMaybe<TSourcePtr>(nullptr);