Skip to content

Commit

Permalink
fix(fuzzer): Make Join Fuzzer fail when query fails in reference DB (f…
Browse files Browse the repository at this point in the history
…acebookincubator#12131)

Summary:
Pull Request resolved: facebookincubator#12131

The change in D66977480 casued the Join Fuzzer to no longer throw when queries fail in the reference DB. This change returns that behavior in the Join Fuzzer.

Reviewed By: kagamiori

Differential Revision: D68428128

fbshipit-source-id: 1d7f29c98dde9336d8a1d220a891e85936a1ff00
  • Loading branch information
Daniel Hunte authored and facebook-github-bot committed Jan 24, 2025
1 parent edd7e8f commit e803ae3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
16 changes: 6 additions & 10 deletions velox/exec/fuzzer/JoinFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,12 +680,8 @@ std::optional<MaterializedRowMultiset> JoinFuzzer::computeReferenceResults(
}

auto result = referenceQueryRunner_->execute(plan);
if (result.first) {
return result.first;
}

LOG(INFO) << "Query not supported by or failed in the reference DB";
return std::nullopt;
VELOX_CHECK_NE(result.second, ReferenceQueryErrorCode::kReferenceQueryFail);
return result.first;
}

std::vector<std::string> fieldNames(
Expand Down Expand Up @@ -1014,8 +1010,8 @@ RowVectorPtr JoinFuzzer::testCrossProduct(
/*filter=*/"");
const auto expected = execute(plan, /*injectSpill=*/false);

// If OOM injection is not enabled verify the results against Reference query
// runner.
// If OOM injection is not enabled verify the results against Reference
// query runner.
if (!FLAGS_enable_oom_injection) {
if (auto referenceResult =
computeReferenceResults(plan.plan, probeInput, buildInput)) {
Expand Down Expand Up @@ -1170,8 +1166,8 @@ void JoinFuzzer::verify(core::JoinType joinType) {

const auto expected = execute(defaultPlan, /*injectSpill=*/false);

// If OOM injection is not enabled verify the results against Reference query
// runner.
// If OOM injection is not enabled verify the results against Reference
// query runner.
if (!FLAGS_enable_oom_injection) {
if (auto referenceResult =
computeReferenceResults(defaultPlan.plan, probeInput, buildInput)) {
Expand Down
29 changes: 21 additions & 8 deletions velox/exec/fuzzer/ReferenceQueryRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ enum ReferenceQueryErrorCode {
kReferenceQueryUnsupported
};

FOLLY_ALWAYS_INLINE std::string format_as(ReferenceQueryErrorCode errorCode) {
switch (errorCode) {
case ReferenceQueryErrorCode::kSuccess:
return "kSuccess";
case ReferenceQueryErrorCode::kReferenceQueryFail:
return "kReferenceQueryFail";
case ReferenceQueryErrorCode::kReferenceQueryUnsupported:
return "kReferenceQueryUnsupported";
default:
return "Unknown";
}
}

/// Query runner that uses reference database, i.e. DuckDB, Presto, Spark.
class ReferenceQueryRunner {
public:
Expand All @@ -43,8 +56,8 @@ class ReferenceQueryRunner {
kSparkQueryRunner
};

// @param aggregatePool Used to allocate memory needed for vectors produced by
// 'execute' methods.
// @param aggregatePool Used to allocate memory needed for vectors produced
// by 'execute' methods.
explicit ReferenceQueryRunner(memory::MemoryPool* aggregatePool)
: aggregatePool_(aggregatePool) {}

Expand Down Expand Up @@ -88,8 +101,8 @@ class ReferenceQueryRunner {
return true;
}

/// Returns whether types contained in a function signature are all supported
/// by the reference database.
/// Returns whether types contained in a function signature are all
/// supported by the reference database.
virtual bool isSupported(const exec::FunctionSignature& /*signature*/) {
return true;
}
Expand All @@ -103,10 +116,10 @@ class ReferenceQueryRunner {
VELOX_UNSUPPORTED();
}

// Converts 'plan' into an SQL query and executes it. Result is returned as a
// MaterializedRowMultiset with the ReferenceQueryErrorCode::kSuccess if
// successful, or an std::nullopt with a ReferenceQueryErrorCode if the query
// fails.
// Converts 'plan' into an SQL query and executes it. Result is returned as
// a MaterializedRowMultiset with the ReferenceQueryErrorCode::kSuccess if
// successful, or an std::nullopt with a ReferenceQueryErrorCode if the
// query fails.
virtual std::pair<
std::optional<std::multiset<std::vector<velox::variant>>>,
ReferenceQueryErrorCode>
Expand Down

0 comments on commit e803ae3

Please sign in to comment.