diff options
author | aneporada <aneporada@ydb.tech> | 2022-09-02 08:54:05 +0300 |
---|---|---|
committer | aneporada <aneporada@ydb.tech> | 2022-09-02 08:54:05 +0300 |
commit | d4a0ee7cb80faa47064f5fa2493d0f0e2b6de508 (patch) | |
tree | d4ff85be81396a965122394f63a1ab78b9b99551 | |
parent | 51a224bb8b00edadf75a9040ddcb4dbce8382a14 (diff) | |
download | ydb-d4a0ee7cb80faa47064f5fa2493d0f0e2b6de508.tar.gz |
[] Fix ExtractMembers optimizer - do not select syntetic columns as a 'light' column
-rw-r--r-- | ydb/library/yql/providers/s3/provider/yql_s3_logical_opt.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/ydb/library/yql/providers/s3/provider/yql_s3_logical_opt.cpp b/ydb/library/yql/providers/s3/provider/yql_s3_logical_opt.cpp index 4f79b8fa72..e41a804261 100644 --- a/ydb/library/yql/providers/s3/provider/yql_s3_logical_opt.cpp +++ b/ydb/library/yql/providers/s3/provider/yql_s3_logical_opt.cpp @@ -468,8 +468,25 @@ public: const TStructExprType* readRowType = dqSource.Input().Maybe<TS3ParseSettings>().Cast().RowType().Ref().GetTypeAnn()->Cast<TTypeExprType>()->GetType()->Cast<TStructExprType>(); - if (outputRowType->GetSize() == 0 && readRowType->GetSize() != 0) { - auto item = GetLightColumn(*readRowType); + TVector<const TItemExprType*> readRowDataItems = readRowType->GetItems(); + TVector<const TItemExprType*> outputRowDataItems = outputRowType->GetItems(); + + if (auto settings = dqSource.Input().Maybe<TS3ParseSettings>().Cast().Settings()) { + if (auto ps = GetSetting(settings.Cast().Ref(), "partitionedby")) { + THashSet<TStringBuf> cols; + for (size_t i = 1; i < ps->ChildrenSize(); ++i) { + YQL_ENSURE(ps->Child(i)->IsAtom()); + cols.insert(ps->Child(i)->Content()); + } + auto isPartitionedBy = [&](const auto& item) { return cols.contains(item->GetName()); }; + EraseIf(readRowDataItems, isPartitionedBy); + EraseIf(outputRowDataItems, isPartitionedBy); + } + } + + if (outputRowDataItems.size() == 0 && readRowDataItems.size() != 0) { + const TStructExprType* readRowDataType = ctx.MakeType<TStructExprType>(readRowDataItems); + auto item = GetLightColumn(*readRowDataType); YQL_ENSURE(item); readRowType = ctx.MakeType<TStructExprType>(TVector<const TItemExprType*>{item}); } else { |