diff options
author | vitya-smirnov <[email protected]> | 2025-06-18 17:03:59 +0300 |
---|---|---|
committer | vitya-smirnov <[email protected]> | 2025-06-18 17:40:32 +0300 |
commit | 0ac6c9eac8c5c9d71141af3c89f7cfc1b66a279e (patch) | |
tree | 54b115e79e90c7c8253dec042c81035e4c071cb8 /yql/essentials/sql/v1/complete/analysis/global/global.cpp | |
parent | 93d0e40990c109589c2afd7e2758dc107064fa4e (diff) |
YQL-19747: Support table aliases
commit_hash:6d67ec1fa5023083debd89aaa99950019ca37c90
Diffstat (limited to 'yql/essentials/sql/v1/complete/analysis/global/global.cpp')
-rw-r--r-- | yql/essentials/sql/v1/complete/analysis/global/global.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/yql/essentials/sql/v1/complete/analysis/global/global.cpp b/yql/essentials/sql/v1/complete/analysis/global/global.cpp index 7574b6bdfc0..f73cad926e3 100644 --- a/yql/essentials/sql/v1/complete/analysis/global/global.cpp +++ b/yql/essentials/sql/v1/complete/analysis/global/global.cpp @@ -15,6 +15,15 @@ namespace NSQLComplete { + TVector<TTableId> TColumnContext::TablesWithAlias(TStringBuf alias) const { + if (alias.empty()) { + return TVector<TTableId>(Tables.begin(), Tables.end()); + } + + auto filtered = NFuncTools::Filter([&](const auto& x) { return x.Alias == alias; }, Tables); + return TVector<TTableId>(filtered.begin(), filtered.end()); + } + class TErrorStrategy: public antlr4::DefaultErrorStrategy { public: antlr4::Token* singleTokenDeletion(antlr4::Parser* /* recognizer */) override { @@ -117,6 +126,12 @@ namespace NSQLComplete { } // namespace NSQLComplete template <> +void Out<NSQLComplete::TAliased<NSQLComplete::TTableId>>(IOutputStream& out, const NSQLComplete::TAliased<NSQLComplete::TTableId>& value) { + Out<NSQLComplete::TTableId>(out, value); + out << " AS " << value.Alias; +} + +template <> void Out<NSQLComplete::TColumnContext>(IOutputStream& out, const NSQLComplete::TColumnContext& value) { out << "TColumnContext { "; out << "Tables: " << JoinSeq(", ", value.Tables); |