aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authora-romanov <Anton.Romanov@ydb.tech>2023-07-06 22:33:30 +0300
committera-romanov <Anton.Romanov@ydb.tech>2023-07-06 22:33:30 +0300
commita106ebbbe062aa4b0c17a246be1acf8da6785556 (patch)
tree58e8864554c372b3c5299bb40446c701091aa2a6
parent1b6c51c2d887995831115e83dcdb4354333f5390 (diff)
downloadydb-a106ebbbe062aa4b0c17a246be1acf8da6785556.tar.gz
YQL-8971 YQL-15555 Fix calculate unique for EquiJoin.
-rw-r--r--ydb/library/yql/core/yql_join.cpp12
-rw-r--r--ydb/library/yql/core/yql_join.h1
2 files changed, 11 insertions, 2 deletions
diff --git a/ydb/library/yql/core/yql_join.cpp b/ydb/library/yql/core/yql_join.cpp
index c1e45629888..16dcbbdfc04 100644
--- a/ydb/library/yql/core/yql_join.cpp
+++ b/ydb/library/yql/core/yql_join.cpp
@@ -193,7 +193,8 @@ namespace {
std::vector<std::string_view> lCheck;
lCheck.reserve(leftKeys.size());
for (const auto& x : leftKeys) {
- lCheck.emplace_back(ctx.AppendString((*labels.FindInput(x.first))->FullName(x.second)));
+ for (const auto& name : (*labels.FindInput(x.first))->AllNames(x.second))
+ lCheck.emplace_back(ctx.AppendString(name));
if (!myLeftScope.contains(x.first)) {
ctx.AddError(TIssue(ctx.GetPosition(joins.Pos()),
TStringBuilder() << "Correlation name " << x.first << " is out of scope"));
@@ -212,7 +213,8 @@ namespace {
std::vector<std::string_view> rCheck;
rCheck.reserve(rightKeys.size());
for (const auto& x : rightKeys) {
- rCheck.emplace_back(ctx.AppendString((*labels.FindInput(x.first))->FullName(x.second)));
+ for (const auto& name : (*labels.FindInput(x.first))->AllNames(x.second))
+ rCheck.emplace_back(ctx.AppendString(name));
if (!myRightScope.contains(x.first)) {
ctx.AddError(TIssue(ctx.GetPosition(joins.Pos()),
TStringBuilder() << "Correlation name " << x.first << " is out of scope"));
@@ -545,6 +547,12 @@ TString TJoinLabel::FullName(const TStringBuf& column) const {
}
}
+TVector<TString> TJoinLabel::AllNames(const TStringBuf& column) const {
+ TVector<TString> result(Tables.size());
+ std::transform(Tables.cbegin(), Tables.cend(), result.begin(), std::bind(&FullColumnName, std::placeholders::_1, std::cref(column)));
+ return result;
+}
+
TStringBuf TJoinLabel::ColumnName(const TStringBuf& column) const {
auto pos = column.find('.');
if (pos == TString::npos) {
diff --git a/ydb/library/yql/core/yql_join.h b/ydb/library/yql/core/yql_join.h
index a830cd7d422..fd182d40203 100644
--- a/ydb/library/yql/core/yql_join.h
+++ b/ydb/library/yql/core/yql_join.h
@@ -25,6 +25,7 @@ struct TJoinLabel {
TMaybe<TIssue> Parse(TExprContext& ctx, TExprNode& node, const TStructExprType* structType, const TUniqueConstraintNode* unique, const TDistinctConstraintNode* distinct);
TMaybe<TIssue> ValidateLabel(TExprContext& ctx, const NNodes::TCoAtom& label);
TString FullName(const TStringBuf& column) const;
+ TVector<TString> AllNames(const TStringBuf& column) const;
TStringBuf ColumnName(const TStringBuf& column) const;
TStringBuf TableName(const TStringBuf& column) const;
bool HasTable(const TStringBuf& table) const;