Skip to content

Commit

Permalink
Fix ToFlow for dict join (#2267)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikvas0 authored Feb 27, 2024
1 parent 5cd47d3 commit 6a51e53
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
25 changes: 25 additions & 0 deletions ydb/core/kqp/ut/query/kqp_query_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,31 @@ Y_UNIT_TEST_SUITE(KqpQuery) {
UNIT_ASSERT_VALUES_EQUAL(result.GetResultSet(0).RowsCount(), 1);
}
}

Y_UNIT_TEST(DictJoin) {
TKikimrRunner kikimr;
auto client = kikimr.GetQueryClient();

{
const TString sql = R"(
--!syntax_v1
$lsource = SELECT 'test' AS ldata;
$rsource = SELECT 'test' AS rdata;
$left = SELECT ROW_NUMBER() OVER w AS r, ldata FROM $lsource WINDOW w AS ();
$right = SELECT ROW_NUMBER() OVER w AS r, rdata FROM $rsource WINDOW w AS ();
$result = SELECT ldata, rdata FROM $left AS tl INNER JOIN $right AS tr ON tl.r = tr.r;
SELECT * FROM $result;
)";
auto result = client.ExecuteQuery(
sql,
NYdb::NQuery::TTxControl::BeginTx().CommitTx()).GetValueSync();
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
}
}
}

} // namespace NKqp
Expand Down
4 changes: 3 additions & 1 deletion ydb/library/yql/dq/opt/dq_opt_peephole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,9 @@ NNodes::TExprBase DqPeepholeRewriteJoinDict(const NNodes::TExprBase& node, TExpr
auto unpackData = UnpackJoinedData(leftRowType, rightRowType, leftTableLabel, rightTableLabel, join.Pos(), ctx);

return Build<TCoMap>(ctx, joinDict.Pos())
.Input(join)
.Input<TCoToFlow>()
.Input(join)
.Build()
.Lambda(unpackData)
.Done();
}
Expand Down

0 comments on commit 6a51e53

Please sign in to comment.