Skip to content

Commit

Permalink
Merge branch 'tickets/DM-38621'
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzm committed Apr 8, 2023
2 parents f2473f5 + 2e72ff9 commit 074fcbc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 44 deletions.
13 changes: 6 additions & 7 deletions src/qana/QservRestrictorPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,15 @@ std::shared_ptr<query::SecIdxInRestrictor> makeSecondaryIndexRestrictor(query::I
}

/**
* @brief Make a Secondary Index comparison restrictor for the given between predicate, if one of the
* @brief Make a Secondary Index 'between' restrictor for the given between predicate, if one of the
* columns in the predicate is a director column.
*
* @param betweenPredicate
* @param context
* @return std::shared_ptr<query::SIBetweenRestr> The restrictor that corresponds to the given predicate if
* one of the columns is a director column, otherwise nullptr.
*/
std::shared_ptr<query::SecIdxBetweenRestrictor> makeSecondaryIndexRestrictor(
[[maybe_unused]] std::shared_ptr<query::SecIdxBetweenRestrictor> makeSecondaryIndexRestrictor(
query::BetweenPredicate const& betweenPredicate, query::QueryContext const& context) {
if (isSecIndexCol(context, betweenPredicate.value->getColumnRef())) {
auto dirCol = getCorrespondingDirectorColumn(context, betweenPredicate.value->getColumnRef());
Expand All @@ -362,7 +362,7 @@ std::shared_ptr<query::SecIdxBetweenRestrictor> makeSecondaryIndexRestrictor(
}

/**
* @brief Make a Secondary Index 'between' restrictor for the given comparison predicate, if one of the
* @brief Make a Secondary Index comparison restrictor for the given comparison predicate, if one of the
* columns in the comparison predicate is a director column.
*
* @param compPredicate
Expand Down Expand Up @@ -419,10 +419,9 @@ std::vector<std::shared_ptr<query::SecIdxRestrictor>> getSecIndexRestrictors(que
restrictor = makeSecondaryIndexRestrictor(*inPredicate, context);
} else if (auto const compPredicate =
std::dynamic_pointer_cast<query::CompPredicate>(factorTerm)) {
restrictor = makeSecondaryIndexRestrictor(*compPredicate, context);
} else if (auto const betweenPredicate =
std::dynamic_pointer_cast<query::BetweenPredicate>(factorTerm)) {
restrictor = makeSecondaryIndexRestrictor(*betweenPredicate, context);
if (compPredicate->op == query::CompPredicate::EQUALS_OP) {
restrictor = makeSecondaryIndexRestrictor(*compPredicate, context);
}
}
if (restrictor) {
LOGS(_log, LOG_LVL_TRACE, "Add restrictor: " << *restrictor << " for " << factorTerm);
Expand Down
42 changes: 5 additions & 37 deletions src/qproc/testQueryAnaBetween.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,7 @@ BOOST_AUTO_TEST_CASE(SecondaryIndex) {
std::shared_ptr<QueryContext> context = qs->dbgGetContext();
BOOST_CHECK(context);
BOOST_CHECK_EQUAL(context->dominantDb, std::string("LSST"));
BOOST_REQUIRE(context->secIdxRestrictors);
BOOST_CHECK_EQUAL(context->secIdxRestrictors->size(), 1U);
BOOST_REQUIRE(context->secIdxRestrictors->front());
auto betweenRestr =
std::dynamic_pointer_cast<SecIdxBetweenRestrictor>(context->secIdxRestrictors->front());
BOOST_REQUIRE(nullptr != betweenRestr);
BOOST_REQUIRE_EQUAL(
betweenRestr->getSecIdxLookupQuery(lsst::qserv::SEC_INDEX_DB, "LSST__Object",
lsst::qserv::CHUNK_COLUMN, lsst::qserv::SUB_CHUNK_COLUMN),
"SELECT `" + std::string(lsst::qserv::CHUNK_COLUMN) + "`, " + "`" +
std::string(lsst::qserv::SUB_CHUNK_COLUMN) + "`" + " FROM `" +
std::string(lsst::qserv::SEC_INDEX_DB) + "`" +
".`LSST__Object` WHERE `objectIdObjTest` BETWEEN 386942193651347 AND 386942193651349");
BOOST_REQUIRE(not context->secIdxRestrictors); // since DM-38621
}

BOOST_AUTO_TEST_CASE(NoSecondaryIndex) {
Expand All @@ -115,19 +103,9 @@ BOOST_AUTO_TEST_CASE(DoubleSecondaryIndexRestrictor) {
BOOST_CHECK(context);
BOOST_CHECK_EQUAL(context->dominantDb, std::string("LSST"));
BOOST_REQUIRE(context->secIdxRestrictors);
BOOST_CHECK_EQUAL(context->secIdxRestrictors->size(), 2U);
BOOST_CHECK_EQUAL(context->secIdxRestrictors->size(), 1U); // since DM-38621
BOOST_REQUIRE(context->secIdxRestrictors->at(0));
auto betweenRestr = std::dynamic_pointer_cast<SecIdxBetweenRestrictor>(context->secIdxRestrictors->at(0));
BOOST_REQUIRE(betweenRestr != nullptr);
BOOST_REQUIRE_EQUAL(
betweenRestr->getSecIdxLookupQuery(lsst::qserv::SEC_INDEX_DB, "LSST__Object",
lsst::qserv::CHUNK_COLUMN, lsst::qserv::SUB_CHUNK_COLUMN),
"SELECT `" + std::string(lsst::qserv::CHUNK_COLUMN) + "`, " + "`" +
std::string(lsst::qserv::SUB_CHUNK_COLUMN) + "`" + " FROM " + "`" +
std::string(lsst::qserv::SEC_INDEX_DB) + "`" +
".`LSST__Object` WHERE `objectIdObjTest` BETWEEN 38 AND 40");
BOOST_REQUIRE(context->secIdxRestrictors->at(1));
auto inRestrictor = std::dynamic_pointer_cast<SecIdxInRestrictor>(context->secIdxRestrictors->at(1));
auto inRestrictor = std::dynamic_pointer_cast<SecIdxInRestrictor>(context->secIdxRestrictors->at(0));
BOOST_REQUIRE(inRestrictor != nullptr);
BOOST_REQUIRE_EQUAL(
inRestrictor->getSecIdxLookupQuery(lsst::qserv::SEC_INDEX_DB, "LSST__Object",
Expand All @@ -153,19 +131,9 @@ BOOST_AUTO_TEST_CASE(DoubleSecondaryIndexRestrictorCartesian) {
BOOST_CHECK(context);
BOOST_CHECK_EQUAL(context->dominantDb, std::string("LSST"));
BOOST_REQUIRE(context->secIdxRestrictors);
BOOST_CHECK_EQUAL(context->secIdxRestrictors->size(), 2U);
BOOST_CHECK_EQUAL(context->secIdxRestrictors->size(), 1U); // since DM-38621
BOOST_REQUIRE(context->secIdxRestrictors->at(0));
auto betweenRestr = std::dynamic_pointer_cast<SecIdxBetweenRestrictor>(context->secIdxRestrictors->at(0));
BOOST_REQUIRE(betweenRestr != nullptr);
BOOST_REQUIRE_EQUAL(
betweenRestr->getSecIdxLookupQuery(lsst::qserv::SEC_INDEX_DB, "LSST__Object",
lsst::qserv::CHUNK_COLUMN, lsst::qserv::SUB_CHUNK_COLUMN),
"SELECT `" + std::string(lsst::qserv::CHUNK_COLUMN) + "`, " + "`" +
std::string(lsst::qserv::SUB_CHUNK_COLUMN) + "`" + " FROM `" +
std::string(lsst::qserv::SEC_INDEX_DB) + "`" +
".`LSST__Object` WHERE `objectIdObjTest` BETWEEN 38 AND 40");
BOOST_REQUIRE(context->secIdxRestrictors->at(1));
auto inRestrictor = std::dynamic_pointer_cast<SecIdxInRestrictor>(context->secIdxRestrictors->at(1));
auto inRestrictor = std::dynamic_pointer_cast<SecIdxInRestrictor>(context->secIdxRestrictors->at(0));
BOOST_REQUIRE(inRestrictor != nullptr);
BOOST_REQUIRE_EQUAL(
inRestrictor->getSecIdxLookupQuery(lsst::qserv::SEC_INDEX_DB, "LSST__Object",
Expand Down

0 comments on commit 074fcbc

Please sign in to comment.