Skip to content

Commit 6a51e53

Browse files
authored
Fix ToFlow for dict join (#2267)
1 parent 5cd47d3 commit 6a51e53

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

ydb/core/kqp/ut/query/kqp_query_ut.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,31 @@ Y_UNIT_TEST_SUITE(KqpQuery) {
15591559
UNIT_ASSERT_VALUES_EQUAL(result.GetResultSet(0).RowsCount(), 1);
15601560
}
15611561
}
1562+
1563+
Y_UNIT_TEST(DictJoin) {
1564+
TKikimrRunner kikimr;
1565+
auto client = kikimr.GetQueryClient();
1566+
1567+
{
1568+
const TString sql = R"(
1569+
--!syntax_v1
1570+
1571+
$lsource = SELECT 'test' AS ldata;
1572+
$rsource = SELECT 'test' AS rdata;
1573+
1574+
$left = SELECT ROW_NUMBER() OVER w AS r, ldata FROM $lsource WINDOW w AS ();
1575+
$right = SELECT ROW_NUMBER() OVER w AS r, rdata FROM $rsource WINDOW w AS ();
1576+
1577+
$result = SELECT ldata, rdata FROM $left AS tl INNER JOIN $right AS tr ON tl.r = tr.r;
1578+
1579+
SELECT * FROM $result;
1580+
)";
1581+
auto result = client.ExecuteQuery(
1582+
sql,
1583+
NYdb::NQuery::TTxControl::BeginTx().CommitTx()).GetValueSync();
1584+
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
1585+
}
1586+
}
15621587
}
15631588

15641589
} // namespace NKqp

ydb/library/yql/dq/opt/dq_opt_peephole.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,9 @@ NNodes::TExprBase DqPeepholeRewriteJoinDict(const NNodes::TExprBase& node, TExpr
554554
auto unpackData = UnpackJoinedData(leftRowType, rightRowType, leftTableLabel, rightTableLabel, join.Pos(), ctx);
555555

556556
return Build<TCoMap>(ctx, joinDict.Pos())
557-
.Input(join)
557+
.Input<TCoToFlow>()
558+
.Input(join)
559+
.Build()
558560
.Lambda(unpackData)
559561
.Done();
560562
}

0 commit comments

Comments
 (0)