Skip to content

Commit ddd1377

Browse files
committed
Explicitly mark join options as cached/non-cached
commit_hash:2b628a932727d94de42946b50e645d7b96338f48
1 parent db299e1 commit ddd1377

File tree

2 files changed

+46
-33
lines changed

2 files changed

+46
-33
lines changed

yql/essentials/core/yql_join.cpp

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,18 @@ namespace {
340340
else if (option.IsAtom("join_algo")) {
341341
//do nothing
342342
}
343-
else if (option.IsAtom("shuffle_lhs_by") || option.IsAtom("shuffle_rhs_by")) {
344-
//do nothing
345-
}
346343
else if (option.IsAtom("compact")) {
347344
if (!EnsureTupleSize(*child, 1, ctx)) {
348345
return IGraphTransformer::TStatus::Error;
349346
}
350347
}
348+
else if (IsCachedJoinLinkOption(option.Content())) {
349+
if (option.IsAtom("shuffle_lhs_by") || option.IsAtom("shuffle_rhs_by")) {
350+
//do nothing
351+
} else {
352+
YQL_ENSURE(false, "Cached join link option '" << option.Content() << "' not handled");
353+
}
354+
}
351355
else {
352356
ctx.AddError(TIssue(ctx.GetPosition(option.Pos()), TStringBuilder() <<
353357
"Unknown option name: " << option.Content()));
@@ -787,40 +791,38 @@ IGraphTransformer::TStatus ValidateEquiJoinOptions(TPositionHandle positionHandl
787791
options.Flatten = true;
788792
} else if (optionName == "strict_keys") {
789793
options.StrictKeys = true;
790-
} else if (optionName == "preferred_sort") {
791-
THashSet<TStringBuf> sortBySet;
792-
TVector<TStringBuf> sortBy;
793-
if (!EnsureTupleSize(*child, 2, ctx)) {
794-
return IGraphTransformer::TStatus::Error;
795-
}
796-
if (!EnsureTupleMinSize(*child->Child(1), 1, ctx)) {
797-
return IGraphTransformer::TStatus::Error;
798-
}
799-
for (auto column : child->Child(1)->Children()) {
800-
if (!EnsureAtom(*column, ctx)) {
794+
} else if (IsCachedJoinOption(optionName)) {
795+
if (optionName == "preferred_sort") {
796+
THashSet<TStringBuf> sortBySet;
797+
TVector<TStringBuf> sortBy;
798+
if (!EnsureTupleSize(*child, 2, ctx)) {
801799
return IGraphTransformer::TStatus::Error;
802800
}
803-
if (!sortBySet.insert(column->Content()).second) {
804-
ctx.AddError(TIssue(ctx.GetPosition(column->Pos()), TStringBuilder() <<
805-
"Duplicated preferred_sort column: " << column->Content()));
801+
if (!EnsureTupleMinSize(*child->Child(1), 1, ctx)) {
806802
return IGraphTransformer::TStatus::Error;
807803
}
808-
sortBy.push_back(column->Content());
809-
}
810-
if (!options.PreferredSortSets.insert(sortBy).second) {
811-
ctx.AddError(TIssue(ctx.GetPosition(child->Child(1)->Pos()), TStringBuilder() <<
812-
"Duplicated preferred_sort set: " << JoinSeq(", ", sortBy)));
804+
for (auto column : child->Child(1)->Children()) {
805+
if (!EnsureAtom(*column, ctx)) {
806+
return IGraphTransformer::TStatus::Error;
807+
}
808+
if (!sortBySet.insert(column->Content()).second) {
809+
ctx.AddError(TIssue(ctx.GetPosition(column->Pos()), TStringBuilder() <<
810+
"Duplicated preferred_sort column: " << column->Content()));
811+
return IGraphTransformer::TStatus::Error;
812+
}
813+
sortBy.push_back(column->Content());
814+
}
815+
if (!options.PreferredSortSets.insert(sortBy).second) {
816+
ctx.AddError(TIssue(ctx.GetPosition(child->Child(1)->Pos()), TStringBuilder() <<
817+
"Duplicated preferred_sort set: " << JoinSeq(", ", sortBy)));
818+
}
819+
} else if (optionName == "cbo_passed") {
820+
// do nothing
821+
} else if (optionName == "multiple_joins") {
822+
// do nothing
823+
} else {
824+
YQL_ENSURE(false, "Cached join option '" << optionName << "' not handled");
813825
}
814-
} else if (optionName == "cbo_passed") {
815-
// do nothing
816-
} else if (optionName == "join_algo") {
817-
// do nothing
818-
} else if (optionName == "shuffle_lhs_by" || optionName == "shuffle_rhs_by") {
819-
// do nothing
820-
} else if (optionName == "multiple_joins") {
821-
// do nothing
822-
} else if (optionName == "compact") {
823-
options.Compact = true;
824826
} else {
825827
ctx.AddError(TIssue(position, TStringBuilder() <<
826828
"Unknown option name: " << optionName));
@@ -2004,4 +2006,14 @@ void GatherJoinInputs(const TExprNode::TPtr& expr, const TExprNode& row,
20042006
}
20052007
}
20062008

2009+
bool IsCachedJoinOption(TStringBuf name) {
2010+
static THashSet<TStringBuf> CachedJoinOptions = {"preferred_sort", "cbo_passed", "multiple_joins"};
2011+
return CachedJoinOptions.contains(name);
2012+
}
2013+
2014+
bool IsCachedJoinLinkOption(TStringBuf name) {
2015+
static THashSet<TStringBuf> CachedJoinLinkOptions = {"shuffle_lhs_by", "shuffle_rhs_by"};
2016+
return CachedJoinLinkOptions.contains(name);
2017+
}
2018+
20072019
} // namespace NYql

yql/essentials/core/yql_join.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ struct TJoinOptions {
6060

6161
bool Flatten = false;
6262
bool StrictKeys = false;
63-
bool Compact = false;
6463
};
6564

6665
IGraphTransformer::TStatus ValidateEquiJoinOptions(
@@ -178,5 +177,7 @@ void GatherJoinInputs(const TExprNode::TPtr& expr, const TExprNode& row,
178177
const TParentsMap& parentsMap, const THashMap<TString, TString>& backRenameMap,
179178
const TJoinLabels& labels, TSet<ui32>& inputs, TSet<TStringBuf>& usedFields);
180179

180+
bool IsCachedJoinOption(TStringBuf name);
181+
bool IsCachedJoinLinkOption(TStringBuf name);
181182

182183
}

0 commit comments

Comments
 (0)