Skip to content

Commit

Permalink
Merge 17badf0 into 42c2025
Browse files Browse the repository at this point in the history
  • Loading branch information
yumkam authored Dec 4, 2024
2 parents 42c2025 + 17badf0 commit d101c08
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ Y_UNIT_TEST_SUITE(GenericProviderLookupActor) {
.Operand().Equal().Column("optional_id").OptionalValue<ui64>(100).Done().Done()
.Done()
.Done()
.Operand()
.Conjunction()
.Operand().Equal().Column("id").Value<ui64>(2).Done().Done()
.Operand().Equal().Column("optional_id").OptionalValue<ui64>(102).Done().Done()
.Done()
.Done()
.Done()
.Done()
.Done()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,18 +414,30 @@ namespace NYql::NDq {
select.mutable_from()->Settable(LookupSource.table());

NConnector::NApi::TPredicate_TDisjunction disjunction;
for (const auto& [k, _] : *Request) {
auto addClause = [&disjunction, KeyType = this->KeyType](ui32 columns, auto&& getter) {
NConnector::NApi::TPredicate_TConjunction conjunction;
for (ui32 c = 0; c != KeyType->GetMembersCount(); ++c) {
for (ui32 c = 0; c != columns; ++c) {
NConnector::NApi::TPredicate_TComparison eq;
eq.Setoperation(NConnector::NApi::TPredicate_TComparison_EOperation::TPredicate_TComparison_EOperation_EQ);
eq.mutable_left_value()->Setcolumn(TString(KeyType->GetMemberName(c)));
auto rightTypedValue = eq.mutable_right_value()->mutable_typed_value();
ExportTypeToProto(KeyType->GetMemberType(c), *rightTypedValue->mutable_type());
ExportValueToProto(KeyType->GetMemberType(c), k.GetElement(c), *rightTypedValue->mutable_value());
ExportValueToProto(KeyType->GetMemberType(c), getter(c), *rightTypedValue->mutable_value());
*conjunction.mutable_operands()->Add()->mutable_comparison() = eq;
}
*disjunction.mutable_operands()->Add()->mutable_conjunction() = conjunction;
};
for (const auto& [k, _] : *Request) {
addClause(KeyType->GetMembersCount(), [&k = k](auto c) {
return k.GetElement(c);
});
}
auto& k = Request->begin()->first; // Request is never empty
// Pad query with dummy clauses to improve caching
for (ui32 nRequests = Request->size(); !IsPowerOf2(nRequests) && nRequests < MaxKeysInRequest; ++nRequests) {
addClause(KeyType->GetMembersCount(), [&k = k](auto c) {
return k.GetElement(c);
});
}
*select.mutable_where()->mutable_filter_typed()->mutable_disjunction() = disjunction;
return {};
Expand Down

0 comments on commit d101c08

Please sign in to comment.