aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraakulaga <aakulaga@ydb.tech>2023-12-11 15:03:18 +0300
committeraakulaga <aakulaga@ydb.tech>2023-12-11 16:42:01 +0300
commitba2f0b10efb15b42797d87396d642cc780d9b618 (patch)
tree990346967c499b2654947ea1a312301542ffce76
parentef18f65a4411ca3c88b54bcd8a8654f5f107757d (diff)
downloadydb-ba2f0b10efb15b42797d87396d642cc780d9b618.tar.gz
Fix any join absence after key columns cast
Fix any join absence after key columns cast
-rw-r--r--ydb/library/yql/dq/opt/dq_opt_join.cpp43
-rw-r--r--ydb/library/yql/tests/sql/dq_file/part0/canondata/result.json24
-rw-r--r--ydb/library/yql/tests/sql/dq_file/part1/canondata/result.json6
-rw-r--r--ydb/library/yql/tests/sql/dq_file/part3/canondata/result.json12
-rw-r--r--ydb/library/yql/tests/sql/dq_file/part4/canondata/result.json6
-rw-r--r--ydb/library/yql/tests/sql/dq_file/part6/canondata/result.json6
6 files changed, 49 insertions, 48 deletions
diff --git a/ydb/library/yql/dq/opt/dq_opt_join.cpp b/ydb/library/yql/dq/opt/dq_opt_join.cpp
index e4cbcb364b..2be9036d66 100644
--- a/ydb/library/yql/dq/opt/dq_opt_join.cpp
+++ b/ydb/library/yql/dq/opt/dq_opt_join.cpp
@@ -431,38 +431,27 @@ TDqJoin DqSuppressSortOnJoinInput(const TDqJoin& join, TExprContext& ctx) {
if (lOrdered && rOrdered)
return Build<TDqJoin>(ctx, join.Pos())
+ .InitFrom(join)
.LeftInput<TCoUnordered>()
.Input(join.LeftInput())
.Build()
.RightInput<TCoUnordered>()
.Input(join.RightInput())
.Build()
- .LeftLabel(join.RightLabel())
- .RightLabel(join.LeftLabel())
- .JoinType(join.JoinType())
- .JoinKeys(join.JoinKeys())
.Done();
else if (lOrdered)
return Build<TDqJoin>(ctx, join.Pos())
+ .InitFrom(join)
.LeftInput<TCoUnordered>()
.Input(join.LeftInput())
.Build()
- .RightInput(join.RightInput())
- .LeftLabel(join.RightLabel())
- .RightLabel(join.LeftLabel())
- .JoinType(join.JoinType())
- .JoinKeys(join.JoinKeys())
.Done();
else if (rOrdered)
return Build<TDqJoin>(ctx, join.Pos())
- .LeftInput(join.LeftInput())
+ .InitFrom(join)
.RightInput<TCoUnordered>()
.Input(join.RightInput())
.Build()
- .LeftLabel(join.RightLabel())
- .RightLabel(join.LeftLabel())
- .JoinType(join.JoinType())
- .JoinKeys(join.JoinKeys())
.Done();
return join;
}
@@ -477,6 +466,22 @@ TExprBase DqRewriteRightJoinToLeft(const TExprBase node, TExprContext& ctx) {
return node;
}
+ TMaybeNode<TCoAtomList> newFlags;
+ if (TMaybeNode<TCoAtomList> flags = dqJoin.Flags()) {
+ auto flagsBuilder = Build<TCoAtomList>(ctx, flags.Cast().Pos());
+ for (auto flag: flags.Cast()) {
+ TStringBuf tail;
+ if( flag.Value().AfterPrefix("Left", tail)) {
+ flagsBuilder.Add().Value("Right" + TString(tail)).Build();
+ } else if ( flag.Value().AfterPrefix("Right", tail)) {
+ flagsBuilder.Add().Value("Left" + TString(tail)).Build();
+ } else {
+ flagsBuilder.Add(flag);
+ }
+ }
+ newFlags = flagsBuilder.Done();
+ }
+
auto joinKeysBuilder = Build<TDqJoinKeyTupleList>(ctx, dqJoin.Pos());
for (const auto& keys : dqJoin.JoinKeys()) {
joinKeysBuilder.Add<TDqJoinKeyTuple>()
@@ -496,6 +501,7 @@ TExprBase DqRewriteRightJoinToLeft(const TExprBase node, TExprContext& ctx) {
.Value(RotateRightJoinType(dqJoin.JoinType().Value()))
.Build()
.JoinKeys(joinKeysBuilder.Done())
+ .Flags(newFlags)
.Done();
}
@@ -552,12 +558,9 @@ TExprBase DqRewriteLeftPureJoin(const TExprBase node, TExprContext& ctx, const T
// all right input data to single task, we can do a "partial" right semi join
// on in the right stage to extract only necessary rows.
return Build<TDqJoin>(ctx, join.Pos())
+ .InitFrom(join)
.LeftInput(leftConnection)
- .LeftLabel(join.LeftLabel())
- .RightInput(join.RightInput())
- .RightLabel(join.RightLabel())
.JoinType().Build(joinType)
- .JoinKeys(join.JoinKeys())
.Done();
}
@@ -1179,11 +1182,9 @@ TExprBase DqBuildHashJoin(const TDqJoin& join, EHashJoinMode mode, TExprContext&
return Build<TCoExtractMembers>(ctx, join.Pos())
.Input<TDqJoin>()
+ .InitFrom(join)
.LeftInput(connLeft)
- .LeftLabel(join.LeftLabel())
.RightInput(connRight)
- .RightLabel(join.RightLabel())
- .JoinType(join.JoinType())
.JoinKeys(ctx.ChangeChildren(join.JoinKeys().Ref(), std::move(joinKeys)))
.Build()
.Members().Add(std::move(fields)).Build()
diff --git a/ydb/library/yql/tests/sql/dq_file/part0/canondata/result.json b/ydb/library/yql/tests/sql/dq_file/part0/canondata/result.json
index 595f7f430f..4ed2f663b6 100644
--- a/ydb/library/yql/tests/sql/dq_file/part0/canondata/result.json
+++ b/ydb/library/yql/tests/sql/dq_file/part0/canondata/result.json
@@ -2162,23 +2162,23 @@
],
"test.test[join-anyjoin_common_nodup--Analyze]": [
{
- "checksum": "b768c406e3555c345f1272b2926ebc69",
- "size": 10164,
- "uri": "https://{canondata_backend}/1773845/df65899dab8a6000128816aea623c99e5f1dd537/resource.tar.gz#test.test_join-anyjoin_common_nodup--Analyze_/plan.txt"
+ "checksum": "85d5c17c5324fc77087be67566314a89",
+ "size": 14881,
+ "uri": "https://{canondata_backend}/1130705/6ffd9ee62f7f1ead96b9e0706567eed65aef89a0/resource.tar.gz#test.test_join-anyjoin_common_nodup--Analyze_/plan.txt"
}
],
"test.test[join-anyjoin_common_nodup--Debug]": [
{
- "checksum": "f975326581ef38a54043518fc01a5d1a",
- "size": 3827,
- "uri": "https://{canondata_backend}/1773845/df65899dab8a6000128816aea623c99e5f1dd537/resource.tar.gz#test.test_join-anyjoin_common_nodup--Debug_/opt.yql_patched"
+ "checksum": "551f9df10ae8808fc00cb959b3e91bc7",
+ "size": 5149,
+ "uri": "https://{canondata_backend}/1130705/6ffd9ee62f7f1ead96b9e0706567eed65aef89a0/resource.tar.gz#test.test_join-anyjoin_common_nodup--Debug_/opt.yql_patched"
}
],
"test.test[join-anyjoin_common_nodup--Plan]": [
{
- "checksum": "b768c406e3555c345f1272b2926ebc69",
- "size": 10164,
- "uri": "https://{canondata_backend}/1936997/0369012b4079b3fe371b0e69a32dd2ddf31664b0/resource.tar.gz#test.test_join-anyjoin_common_nodup--Plan_/plan.txt"
+ "checksum": "85d5c17c5324fc77087be67566314a89",
+ "size": 14881,
+ "uri": "https://{canondata_backend}/1130705/6ffd9ee62f7f1ead96b9e0706567eed65aef89a0/resource.tar.gz#test.test_join-anyjoin_common_nodup--Plan_/plan.txt"
}
],
"test.test[join-anyjoin_common_nodup--Results]": [],
@@ -3040,9 +3040,9 @@
],
"test.test[join-star_join_inners_vk_sorted--Debug]": [
{
- "checksum": "e356f16296e72e429587d8d14a9de4d4",
- "size": 6314,
- "uri": "https://{canondata_backend}/1925821/19d06fd11e73069031119b8b68a5b313a3517c51/resource.tar.gz#test.test_join-star_join_inners_vk_sorted--Debug_/opt.yql_patched"
+ "checksum": "22383e3a17ddf332fdcdcd1ad17729d8",
+ "size": 6341,
+ "uri": "https://{canondata_backend}/1130705/6ffd9ee62f7f1ead96b9e0706567eed65aef89a0/resource.tar.gz#test.test_join-star_join_inners_vk_sorted--Debug_/opt.yql_patched"
}
],
"test.test[join-star_join_inners_vk_sorted--Plan]": [
diff --git a/ydb/library/yql/tests/sql/dq_file/part1/canondata/result.json b/ydb/library/yql/tests/sql/dq_file/part1/canondata/result.json
index 86e6e26fee..0b547d7c69 100644
--- a/ydb/library/yql/tests/sql/dq_file/part1/canondata/result.json
+++ b/ydb/library/yql/tests/sql/dq_file/part1/canondata/result.json
@@ -3067,9 +3067,9 @@
],
"test.test[join-star_join_inners_premap--Debug]": [
{
- "checksum": "8bc381e794584dc2eb1aa5f05e497104",
- "size": 6669,
- "uri": "https://{canondata_backend}/1925821/aed45a97d0ee19043639ca69e3ab611a61e15c4f/resource.tar.gz#test.test_join-star_join_inners_premap--Debug_/opt.yql_patched"
+ "checksum": "6a018d03c1c866bf1b9b2fdd296df943",
+ "size": 6696,
+ "uri": "https://{canondata_backend}/212715/b6db82f532b491a256d95d2d6bb5ea0f39b54778/resource.tar.gz#test.test_join-star_join_inners_premap--Debug_/opt.yql_patched"
}
],
"test.test[join-star_join_inners_premap--Plan]": [
diff --git a/ydb/library/yql/tests/sql/dq_file/part3/canondata/result.json b/ydb/library/yql/tests/sql/dq_file/part3/canondata/result.json
index 04460baafc..dde80ab51c 100644
--- a/ydb/library/yql/tests/sql/dq_file/part3/canondata/result.json
+++ b/ydb/library/yql/tests/sql/dq_file/part3/canondata/result.json
@@ -2760,9 +2760,9 @@
],
"test.test[join-star_join--Debug]": [
{
- "checksum": "2b4d20887048b84d0bd5f3617a99f8d4",
- "size": 9400,
- "uri": "https://{canondata_backend}/1847551/3e6baa066ecfc2254a97988c59db5318c41b136f/resource.tar.gz#test.test_join-star_join--Debug_/opt.yql_patched"
+ "checksum": "5e9c3da1b8748e34cb77cc90ac205725",
+ "size": 9409,
+ "uri": "https://{canondata_backend}/1777230/c29d09c9133ea1887a977fc31e1f9731494b3d96/resource.tar.gz#test.test_join-star_join--Debug_/opt.yql_patched"
}
],
"test.test[join-star_join--Plan]": [
@@ -2782,9 +2782,9 @@
],
"test.test[join-star_join_multi--Debug]": [
{
- "checksum": "d6498c2f636ec57616a9994bee398eee",
- "size": 13731,
- "uri": "https://{canondata_backend}/1899731/5f2ba051437dbbe71df0674617fe1a74e541bb6d/resource.tar.gz#test.test_join-star_join_multi--Debug_/opt.yql_patched"
+ "checksum": "bada8afa8918cb76bbf7188d93ecbe0e",
+ "size": 13748,
+ "uri": "https://{canondata_backend}/1777230/c29d09c9133ea1887a977fc31e1f9731494b3d96/resource.tar.gz#test.test_join-star_join_multi--Debug_/opt.yql_patched"
}
],
"test.test[join-star_join_multi--Plan]": [
diff --git a/ydb/library/yql/tests/sql/dq_file/part4/canondata/result.json b/ydb/library/yql/tests/sql/dq_file/part4/canondata/result.json
index 2aa4d051ee..f456a1dfab 100644
--- a/ydb/library/yql/tests/sql/dq_file/part4/canondata/result.json
+++ b/ydb/library/yql/tests/sql/dq_file/part4/canondata/result.json
@@ -3204,9 +3204,9 @@
],
"test.test[join-star_join_inners--Debug]": [
{
- "checksum": "459fd7923e9a2a6c972a329116eacec3",
- "size": 6301,
- "uri": "https://{canondata_backend}/1925821/df4a21470d774336be6997763f16bf3176d7bfa8/resource.tar.gz#test.test_join-star_join_inners--Debug_/opt.yql_patched"
+ "checksum": "6b10af12310018020e2ab6b55509689e",
+ "size": 6328,
+ "uri": "https://{canondata_backend}/1937429/150bdf6d3fa858efe6ed505334a80ed0be3f9e29/resource.tar.gz#test.test_join-star_join_inners--Debug_/opt.yql_patched"
}
],
"test.test[join-star_join_inners--Plan]": [
diff --git a/ydb/library/yql/tests/sql/dq_file/part6/canondata/result.json b/ydb/library/yql/tests/sql/dq_file/part6/canondata/result.json
index be6f210565..d4f3e33ac3 100644
--- a/ydb/library/yql/tests/sql/dq_file/part6/canondata/result.json
+++ b/ydb/library/yql/tests/sql/dq_file/part6/canondata/result.json
@@ -3065,9 +3065,9 @@
],
"test.test[join-star_join_mirror--Debug]": [
{
- "checksum": "7b5cb1120c4e513ddbdcb6339c3e0ce6",
- "size": 9343,
- "uri": "https://{canondata_backend}/1599023/d7b6e2bf39608f315eb1f698eac7f5a140c76d3c/resource.tar.gz#test.test_join-star_join_mirror--Debug_/opt.yql_patched"
+ "checksum": "fa0dc7c6b48443a8993a8e5842ccc5b9",
+ "size": 9351,
+ "uri": "https://{canondata_backend}/1937001/81e4d5461f74b88d4d5da6893d328d5d2de1dc2b/resource.tar.gz#test.test_join-star_join_mirror--Debug_/opt.yql_patched"
}
],
"test.test[join-star_join_mirror--Plan]": [