Skip to content

Commit

Permalink
YQL-19192 Fix a bug in in-mem cross-join
Browse files Browse the repository at this point in the history
commit_hash:053aa7fb2386f44720aa5fa726f3014791ea9b65
  • Loading branch information
avevad committed Jan 16, 2025
1 parent 52092f0 commit 96a6bd3
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,15 @@ TExprNode::TPtr ExpandEquiJoinImpl(const TExprNode& node, TExprContext& ctx) {
if (joinKind == "Cross") {
return ctx.Builder(node.Pos())
.Callable("FlatMap")
.Add(0, std::move(list1))
.Callable(0, "Collect")
.Add(0, std::move(list1))
.Seal()
.Lambda(1)
.Param("left")
.Callable("Map")
.Add(0, std::move(list2))
.Callable(0, "Collect")
.Add(0, std::move(list2))
.Seal()
.Lambda(1)
.Param("right")
.Callable("AsStruct")
Expand Down
14 changes: 14 additions & 0 deletions yql/essentials/tests/sql/minirun/part1/canondata/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,20 @@
"uri": "https://{canondata_backend}/1936273/dc5c7fc322621a2828a94006237d3583f38248e5/resource.tar.gz#test.test_join-inmem_by_uncomparable_tuples-default.txt-Results_/results.txt"
}
],
"test.test[join-yql-19192-default.txt-Debug]": [
{
"checksum": "b9c6aea35bc8b70c987653997335369d",
"size": 746,
"uri": "https://{canondata_backend}/1814674/dfd418faf4299c20acfad523d570f8cfb90f89ea/resource.tar.gz#test.test_join-yql-19192-default.txt-Debug_/opt.yql"
}
],
"test.test[join-yql-19192-default.txt-Results]": [
{
"checksum": "6e4f62a8d64ea7bbe1a05464bcb80ba4",
"size": 1233,
"uri": "https://{canondata_backend}/1814674/dfd418faf4299c20acfad523d570f8cfb90f89ea/resource.tar.gz#test.test_join-yql-19192-default.txt-Results_/results.txt"
}
],
"test.test[library-library_yqls--Debug]": [
{
"checksum": "b2bab6a1ef79eb44b255b25d32270957",
Expand Down
12 changes: 12 additions & 0 deletions yql/essentials/tests/sql/sql2yql/canondata/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -3443,6 +3443,13 @@
"uri": "https://{canondata_backend}/1942173/99e88108149e222741552e7e6cddef041d6a2846/resource.tar.gz#test_sql2yql.test_join-left_join_with_self_aggr_/sql.yql"
}
],
"test_sql2yql.test[join-yql-19192]": [
{
"checksum": "fffdf1cbb40643da9daf9bdf3edec121",
"size": 2305,
"uri": "https://{canondata_backend}/1937367/af84d06d0fb3153f82b596e7db07f2186d2ec3a2/resource.tar.gz#test_sql2yql.test_join-yql-19192_/sql.yql"
}
],
"test_sql2yql.test[join-yql-6199]": [
{
"checksum": "5421f92ec269e5d76133e1ca54b6d0d0",
Expand Down Expand Up @@ -9242,6 +9249,11 @@
"uri": "file://test_sql_format.test_join-left_join_with_self_aggr_/formatted.sql"
}
],
"test_sql_format.test[join-yql-19192]": [
{
"uri": "file://test_sql_format.test_join-yql-19192_/formatted.sql"
}
],
"test_sql_format.test[join-yql-6199]": [
{
"uri": "file://test_sql_format.test_join-yql-6199_/formatted.sql"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$samples1 = AsList(<|sampl: 1|>, <|sampl: 2|>);
$sampling_cumulative_prob1 = AsList(<|color: 'blue', cum_prob: 3|>);

$cumulative_bounds = (
SELECT
LAG(cum_prob) OVER () AS lower_cum_bound
FROM
AS_TABLE($sampling_cumulative_prob1)
);

SELECT
s.sampl,
cb.lower_cum_bound
FROM
AS_TABLE($samples1) AS s
CROSS JOIN
$cumulative_bounds AS cb
;
12 changes: 12 additions & 0 deletions yql/essentials/tests/sql/suites/join/yql-19192.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$samples1 = AsList(<|sampl: 1|>, <|sampl: 2|>);
$sampling_cumulative_prob1 = AsList(<|color: "blue", cum_prob: 3|>);

$cumulative_bounds = SELECT
LAG(cum_prob) OVER () AS lower_cum_bound
FROM AS_TABLE($sampling_cumulative_prob1);

SELECT
s.sampl,
cb.lower_cum_bound
FROM AS_TABLE($samples1) AS s
CROSS JOIN $cumulative_bounds AS cb;

0 comments on commit 96a6bd3

Please sign in to comment.