Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dq_input_transform_lookup: fix indexes for left-side lookup key #7727

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,25 @@ THashMap<TStringBuf, size_t> GetNameToIndex(const ::google::protobuf::RepeatedPt
return result;
}

THashMap<TStringBuf, size_t> GetNameToIndex(const NMiniKQL::TStructType* type) {
THashMap<TStringBuf, size_t> result;
for (ui32 i = 0; i != type->GetMembersCount(); ++i) {
result[type->GetMemberName(i)] = i;
}
return result;
}

TVector<size_t> GetJoinColumnIndexes(const ::google::protobuf::RepeatedPtrField<TProtoStringType>& names, const THashMap<TStringBuf, size_t>& joinColumns) {
TVector<size_t> result;
result.reserve(joinColumns.size());
for (int i = 0; i != names.size(); ++i) {
if (auto p = joinColumns.FindPtr(names[i])) {
result.push_back(*p);
}
}
return result;
}

TVector<size_t> GetJoinColumnIndexes(const NMiniKQL::TStructType* type, const THashMap<TStringBuf, size_t>& joinColumns) {
TVector<size_t> result;
result.reserve(joinColumns.size());
Expand Down Expand Up @@ -410,14 +429,15 @@ std::pair<IDqComputeActorAsyncInput*, NActors::IActor*> CreateInputTransformStre

const auto rightRowType = DeserializeStructType(settings.GetRightSource().GetSerializedRowType(), args.TypeEnv);

auto leftJoinColumns = GetNameToIndex(settings.GetLeftJoinKeyNames());
auto inputColumns = GetNameToIndex(narrowInputRowType);
auto rightJoinColumns = GetNameToIndex(settings.GetRightJoinKeyNames());
Y_ABORT_UNLESS(leftJoinColumns.size() == rightJoinColumns.size());

auto leftJoinColumnIndexes = GetJoinColumnIndexes(narrowInputRowType, leftJoinColumns);
Y_ABORT_UNLESS(leftJoinColumnIndexes.size() == leftJoinColumns.size());
auto leftJoinColumnIndexes = GetJoinColumnIndexes(
settings.GetLeftJoinKeyNames(),
inputColumns);
auto rightJoinColumnIndexes = GetJoinColumnIndexes(rightRowType, rightJoinColumns);
Y_ABORT_UNLESS(rightJoinColumnIndexes.size() == rightJoinColumns.size());
Y_ABORT_UNLESS(leftJoinColumnIndexes.size() == rightJoinColumnIndexes.size());

const auto& [lookupKeyType, lookupPayloadType] = SplitLookupTableColumns(rightRowType, rightJoinColumns, args.TypeEnv);
const auto& outputColumnsOrder = CategorizeOutputRowItems(
Expand Down
Loading