Skip to content

Commit ea90da3

Browse files
authored
Merge d41beaa into 1ca8874
2 parents 1ca8874 + d41beaa commit ea90da3

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

ydb/core/kqp/ut/join/data/queries/join_order_hints_complex.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ PRAGMA TablePathPrefix='/Root';
22

33
PRAGMA ydb.OptimizerHints =
44
'
5-
Card(Unused # 10e8)
5+
Rows(Unused # 10e8)
66
JoinOrder( (Unused1 Unused2) (Unused3 Unused4) )
77
8-
Card(R # 10e8)
9-
Card(T # 1)
10-
Card(R T # 1)
11-
Card(R S # 10e8)
12-
Card(T U # 10e8)
13-
Card(V # 1)
8+
Rows(R # 10e8)
9+
Rows(T # 1)
10+
Rows(R T # 1)
11+
Rows(R S # 10e8)
12+
Rows(T U # 10e8)
13+
Rows(V # 1)
1414
JoinOrder( (R S) (T U) )
1515
';
1616

ydb/core/kqp/ut/join/data/queries/join_order_hints_many_hint_trees.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ PRAGMA TablePathPrefix='/Root';
22

33
PRAGMA ydb.OptimizerHints =
44
'
5-
Card(R # 10e8)
6-
Card(T # 1)
7-
Card(R T # 1)
8-
Card(R S # 10e8)
9-
Card(T U # 10e8)
10-
Card(V # 1)
5+
Rows(R # 10e8)
6+
Rows(T # 1)
7+
Rows(R T # 1)
8+
Rows(R S # 10e8)
9+
Rows(T U # 10e8)
10+
Rows(V # 1)
1111
JoinOrder(T U)
1212
JoinOrder(R S)
1313
';

ydb/core/kqp/ut/join/data/queries/join_order_hints_simple.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ PRAGMA TablePathPrefix='/Root';
22

33
PRAGMA ydb.OptimizerHints =
44
'
5-
Card(R # 10e8)
6-
Card(T # 1)
7-
Card(S # 10e8)
8-
Card(R T # 1)
9-
Card(R S # 10e8)
5+
Rows(R # 10e8)
6+
Rows(T # 1)
7+
Rows(S # 10e8)
8+
Rows(R T # 1)
9+
Rows(R S # 10e8)
1010
JoinOrder(T (R S))
1111
';
1212

ydb/library/yql/core/cbo/cbo_hints.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class TOptimizerHintsParser {
2222
private:
2323
void Start() {
2424
while (Pos < Size) {
25-
auto hintType = Keyword({"JoinOrder", "JoinAlgo", "Card"});
26-
if (hintType == "JoinOrder") {
27-
JoinOrder();
28-
} else if (hintType == "JoinAlgo") {
29-
JoinAlgo();
30-
} else if (hintType == "Card"){
31-
Card();
25+
auto hintType = Keyword({"JoinOrder", "Leading", "JoinType", "Rows"});
26+
if (hintType == "JoinOrder" || hintType == "Leading") {
27+
JoinOrder(hintType == "Leading");
28+
} else if (hintType == "JoinType") {
29+
JoinType();
30+
} else if (hintType == "Rows"){
31+
Rows();
3232
} else {
3333
ParseError(Sprintf("Undefined hints type: %s", hintType.c_str()), Pos - hintType.Size());
3434
}
@@ -45,43 +45,46 @@ class TOptimizerHintsParser {
4545
return labels;
4646
}
4747

48-
void JoinAlgo() {
48+
void JoinType() {
4949
i32 beginPos = Pos + 1;
5050

5151
Keyword({"("});
5252

5353
i32 labelsBeginPos = Pos + 1;
5454
TVector<TString> labels = CollectLabels();
5555
if (labels.size() <= 1) {
56-
ParseError(Sprintf("Bad labels for JoinAlgo hint: %s, example of the format: JoinAlgo(t1 t2 Grace)", JoinSeq(", ", labels).c_str()), labelsBeginPos);
56+
ParseError(Sprintf("Bad labels for JoinType hint: %s, example of the format: JoinType(t1 t2 Shuffle)", JoinSeq(", ", labels).c_str()), labelsBeginPos);
5757
}
5858
TString reqJoinAlgoStr = std::move(labels.back());
5959
labels.pop_back();
6060

6161
Keyword({")"});
6262

6363
TVector<EJoinAlgoType> joinAlgos = {EJoinAlgoType::GraceJoin, EJoinAlgoType::LookupJoin, EJoinAlgoType::MapJoin};
64-
TVector<TString> joinAlgosStr = {"Grace", "Lookup", "Map"};
64+
TVector<TString> joinAlgosStr = {"Shuffle", "Lookup", "Broadcast"};
6565

66-
for (const auto& [joinAlgo, joinAlgoStr]: Zip(joinAlgos, joinAlgosStr)) {
66+
for (const auto& [JoinType, joinAlgoStr]: Zip(joinAlgos, joinAlgosStr)) {
6767
if (reqJoinAlgoStr == joinAlgoStr) {
68-
Hints.JoinAlgoHints->PushBack(std::move(labels), joinAlgo, "JoinAlgo" + Text.substr(beginPos, Pos - beginPos + 1));
68+
Hints.JoinAlgoHints->PushBack(std::move(labels), JoinType, "JoinType" + Text.substr(beginPos, Pos - beginPos + 1));
6969
return;
7070
}
7171
}
7272

73-
ParseError(Sprintf("Unknown JoinAlgo: '%s', supported algos: [%s]", reqJoinAlgoStr.c_str(), JoinSeq(", ", joinAlgosStr).c_str()), Pos - reqJoinAlgoStr.Size());
73+
ParseError(Sprintf("Unknown JoinType: '%s', supported algos: [%s]", reqJoinAlgoStr.c_str(), JoinSeq(", ", joinAlgosStr).c_str()), Pos - reqJoinAlgoStr.Size());
7474
Y_UNREACHABLE();
7575
}
7676

77-
void JoinOrder() {
77+
void JoinOrder(bool leading /* is keyword "Leading" or "JoinOrder" */) {
7878
i32 beginPos = Pos + 1;
7979

8080
Keyword({"("});
8181
auto joinOrderHintTree = JoinOrderLabels();
8282
Keyword({")"});
8383

84-
Hints.JoinOrderHints->PushBack(std::move(joinOrderHintTree), "JoinOrder" + Text.substr(beginPos, Pos - beginPos + 1));
84+
Hints.JoinOrderHints->PushBack(
85+
std::move(joinOrderHintTree),
86+
leading? "Leading" : "JoinOrder" + Text.substr(beginPos, Pos - beginPos + 1)
87+
);
8588
}
8689

8790
std::shared_ptr<TJoinOrderHints::ITreeNode> JoinOrderLabels() {
@@ -103,7 +106,7 @@ class TOptimizerHintsParser {
103106
Y_UNREACHABLE();
104107
}
105108

106-
void Card() {
109+
void Rows() {
107110
i32 beginPos = Pos + 1;
108111

109112
Keyword({"("});
@@ -124,7 +127,7 @@ class TOptimizerHintsParser {
124127
default: {ParseError(Sprintf("Unknown operation: '%c'", sign), Pos - 1); Y_UNREACHABLE();}
125128
}
126129

127-
Hints.CardinalityHints->PushBack(std::move(labels), op, value, "Card" + Text.substr(beginPos, Pos - beginPos + 1));
130+
Hints.CardinalityHints->PushBack(std::move(labels), op, value, "Rows" + Text.substr(beginPos, Pos - beginPos + 1));
128131
}
129132

130133
private:

0 commit comments

Comments
 (0)