aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorudovichenko-r <rvu@ydb.tech>2023-11-21 14:09:28 +0300
committerudovichenko-r <rvu@ydb.tech>2023-11-21 16:18:27 +0300
commitcd22b385197386dedf6f062b7c4224333659a5ad (patch)
tree52619879849b9bfda2d7bb0ba440883ec82b7939
parent52642c5f2b61158ab7e429edffeecb5253307f8f (diff)
downloadydb-cd22b385197386dedf6f062b7c4224333659a5ad.tar.gz
[yt provider] Fix use-after-free in MultiMapFieldsSubset optimizer
YQL-17143
-rw-r--r--ydb/library/yql/providers/yt/provider/yql_yt_physical_optimize.cpp14
-rw-r--r--ydb/library/yql/tests/sql/yt_native_file/part5/canondata/result.json12
-rw-r--r--ydb/library/yql/tests/sql/yt_native_file/part7/canondata/result.json12
3 files changed, 23 insertions, 15 deletions
diff --git a/ydb/library/yql/providers/yt/provider/yql_yt_physical_optimize.cpp b/ydb/library/yql/providers/yt/provider/yql_yt_physical_optimize.cpp
index b46099f40f..ca46293811 100644
--- a/ydb/library/yql/providers/yt/provider/yql_yt_physical_optimize.cpp
+++ b/ydb/library/yql/providers/yt/provider/yql_yt_physical_optimize.cpp
@@ -5097,12 +5097,20 @@ private:
TSet<TStringBuf> memberSet;
if (HaveFieldsSubset(visitLambda->TailPtr(), visitLambda->Head().Head(), memberSet, *parentsMap)) {
+ auto itemType = visitLambda->Head().Head().GetTypeAnn()->Cast<TStructExprType>();
auto reduceBy = NYql::GetSettingAsColumnList(op.Settings().Ref(), EYtSettingType::ReduceBy);
- memberSet.insert(reduceBy.cbegin(), reduceBy.cend());
+ for (auto& col: reduceBy) {
+ if (auto type = itemType->FindItemType(col)) {
+ memberSet.insert(type->Cast<TItemExprType>()->GetName());
+ }
+ }
auto sortBy = NYql::GetSettingAsColumnList(op.Settings().Ref(), EYtSettingType::SortBy);
- memberSet.insert(sortBy.cbegin(), sortBy.cend());
+ for (auto& col: sortBy) {
+ if (auto type = itemType->FindItemType(col)) {
+ memberSet.insert(type->Cast<TItemExprType>()->GetName());
+ }
+ }
- auto itemType = visitLambda->Head().Head().GetTypeAnn()->Cast<TStructExprType>();
if (memberSet.size() < itemType->GetSize()) {
sectionFields.emplace_back(inputNum, std::move(memberSet));
}
diff --git a/ydb/library/yql/tests/sql/yt_native_file/part5/canondata/result.json b/ydb/library/yql/tests/sql/yt_native_file/part5/canondata/result.json
index 77b891c607..1f7a4367dc 100644
--- a/ydb/library/yql/tests/sql/yt_native_file/part5/canondata/result.json
+++ b/ydb/library/yql/tests/sql/yt_native_file/part5/canondata/result.json
@@ -2849,16 +2849,16 @@
],
"test.test[join-yql-8980--Debug]": [
{
- "checksum": "2f484a92275d10522150eaeb6e3358c4",
- "size": 8625,
- "uri": "https://{canondata_backend}/1903885/bd6e40235810a6cb73de23553bbd4f90ac78f7e5/resource.tar.gz#test.test_join-yql-8980--Debug_/opt.yql"
+ "checksum": "9ef00537c6e3e514212ba20407656ea8",
+ "size": 8686,
+ "uri": "https://{canondata_backend}/1942525/6fb6a099d788b2aeb5f535059064253a6e5a4667/resource.tar.gz#test.test_join-yql-8980--Debug_/opt.yql"
}
],
"test.test[join-yql-8980--Plan]": [
{
- "checksum": "6c10f8b057a6ee89a5400c7102809e03",
- "size": 8552,
- "uri": "https://{canondata_backend}/1689644/9fe79f61eee315131553fff4e7b96fb8a8fb4bba/resource.tar.gz#test.test_join-yql-8980--Plan_/plan.txt"
+ "checksum": "3dd8d73dbe9bec0f6eb61ca60bf11b5c",
+ "size": 9541,
+ "uri": "https://{canondata_backend}/1942525/6fb6a099d788b2aeb5f535059064253a6e5a4667/resource.tar.gz#test.test_join-yql-8980--Plan_/plan.txt"
}
],
"test.test[join-yql-8980--Results]": [
diff --git a/ydb/library/yql/tests/sql/yt_native_file/part7/canondata/result.json b/ydb/library/yql/tests/sql/yt_native_file/part7/canondata/result.json
index 0f93c122c6..e91603bf61 100644
--- a/ydb/library/yql/tests/sql/yt_native_file/part7/canondata/result.json
+++ b/ydb/library/yql/tests/sql/yt_native_file/part7/canondata/result.json
@@ -2146,16 +2146,16 @@
],
"test.test[join-premap_common_multiparents--Debug]": [
{
- "checksum": "e92588219273fede443ec074330680dd",
- "size": 6908,
- "uri": "https://{canondata_backend}/1937424/844c51c227824880c7225d0ff864a8ccce1a32b7/resource.tar.gz#test.test_join-premap_common_multiparents--Debug_/opt.yql"
+ "checksum": "0ddf1a636c00f3595c4bd73658b5ff54",
+ "size": 6943,
+ "uri": "https://{canondata_backend}/1923547/a6eaafd5fa014257fb2d94430d6589d0826d46c5/resource.tar.gz#test.test_join-premap_common_multiparents--Debug_/opt.yql"
}
],
"test.test[join-premap_common_multiparents--Plan]": [
{
- "checksum": "6e44c3d0c321c4b2445171a8c8a6ec93",
- "size": 11408,
- "uri": "https://{canondata_backend}/1936273/871343d6dc76e9a4ae1fb66c0ef95119935a3b0e/resource.tar.gz#test.test_join-premap_common_multiparents--Plan_/plan.txt"
+ "checksum": "e56138a8837cd55a7d1f1553aafbac87",
+ "size": 12109,
+ "uri": "https://{canondata_backend}/1923547/a6eaafd5fa014257fb2d94430d6589d0826d46c5/resource.tar.gz#test.test_join-premap_common_multiparents--Plan_/plan.txt"
}
],
"test.test[join-premap_common_multiparents--Results]": [