summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/complete/analysis/global/use.cpp
diff options
context:
space:
mode:
authorvityaman <[email protected]>2025-06-02 13:23:33 +0300
committerrobot-piglet <[email protected]>2025-06-02 13:49:48 +0300
commitf8dd75681a31f8b883f1c69db243a1ded8bb8d94 (patch)
tree4175cf2925fdc77e7f45bb9f84b65cc06a1a6829 /yql/essentials/sql/v1/complete/analysis/global/use.cpp
parent70ff3797ac5c7fd31a1f092b4074dee5668fa0b1 (diff)
YQL-19747: Complete named expressions
- Introduced scoped name collection at global analysis - Added `BingingsNameService` constructed after global analysis and united with the base service. - Added dollar detection at local analysis. After this point design should be reexamined and module should be refactored. --- - Related to `YQL-19747` - Related to https://github.com/ydb-platform/ydb/issues/9056 - Related to https://github.com/vityaman/ydb/issues/57 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1304 commit_hash:a7bf41703f0ee846e359407b53a5d62fc05928ea
Diffstat (limited to 'yql/essentials/sql/v1/complete/analysis/global/use.cpp')
-rw-r--r--yql/essentials/sql/v1/complete/analysis/global/use.cpp30
1 files changed, 3 insertions, 27 deletions
diff --git a/yql/essentials/sql/v1/complete/analysis/global/use.cpp b/yql/essentials/sql/v1/complete/analysis/global/use.cpp
index 2fd7fab6614..717a35e4e8f 100644
--- a/yql/essentials/sql/v1/complete/analysis/global/use.cpp
+++ b/yql/essentials/sql/v1/complete/analysis/global/use.cpp
@@ -1,19 +1,19 @@
#include "use.h"
#include "evaluate.h"
+#include "narrowing_visitor.h"
namespace NSQLComplete {
namespace {
- class TVisitor: public SQLv1Antlr4BaseVisitor {
+ class TVisitor: public TSQLv1NarrowingVisitor {
public:
TVisitor(
antlr4::TokenStream* tokens,
size_t cursorPosition,
const TEnvironment* env)
- : Tokens_(tokens)
- , CursorPosition_(cursorPosition)
+ : TSQLv1NarrowingVisitor(tokens, cursorPosition)
, Env_(env)
{
}
@@ -61,29 +61,7 @@ namespace NSQLComplete {
return aggregate;
}
- bool shouldVisitNextChild(antlr4::tree::ParseTree* node, const std::any& /*currentResult*/) override {
- return TextInterval(node).a < static_cast<ssize_t>(CursorPosition_);
- }
-
private:
- bool IsEnclosing(antlr4::tree::ParseTree* tree) const {
- return TextInterval(tree).properlyContains(CursorInterval());
- }
-
- antlr4::misc::Interval TextInterval(antlr4::tree::ParseTree* tree) const {
- auto tokens = tree->getSourceInterval();
- if (tokens.b == -1) {
- tokens.b = tokens.a;
- }
- return antlr4::misc::Interval(
- Tokens_->get(tokens.a)->getStartIndex(),
- Tokens_->get(tokens.b)->getStopIndex());
- }
-
- antlr4::misc::Interval CursorInterval() const {
- return antlr4::misc::Interval(CursorPosition_, CursorPosition_);
- }
-
TMaybe<TString> GetId(SQLv1::Pure_column_or_namedContext* ctx) const {
if (auto* x = ctx->bind_parameter()) {
return GetId(x);
@@ -102,8 +80,6 @@ namespace NSQLComplete {
return node.AsString();
}
- antlr4::TokenStream* Tokens_;
- size_t CursorPosition_;
const TEnvironment* Env_;
};