diff --git a/velox/exec/fuzzer/ResultVerifier.h b/velox/exec/fuzzer/ResultVerifier.h index bda5ccecc7f15..74611ce7cf75c 100644 --- a/velox/exec/fuzzer/ResultVerifier.h +++ b/velox/exec/fuzzer/ResultVerifier.h @@ -78,12 +78,20 @@ class ResultVerifier { const RowVectorPtr& result, const RowVectorPtr& otherResult) = 0; + /// Same as above but takes a VectorPtr and converts it to a RowVectorPtr in + /// implementation. + virtual bool compare(const VectorPtr& result, const VectorPtr& altResult) = 0; + /// Verifies results of a Velox plan or reference DB query. /// /// 'initialize' must be called first. 'verify' may be called multiple times /// after single 'initialize' call. virtual bool verify(const RowVectorPtr& result) = 0; + /// Same as above but takes a VectorPtr and converts it to a RowVectorPtr in + /// implementation. + virtual bool verify(const VectorPtr& result) = 0; + /// Clears internal state after possibly multiple calls to 'compare' and /// 'verify'. 'initialize' must be called again after 'reset' to allow calling /// 'compare' or 'verify' again. diff --git a/velox/exec/fuzzer/TransformResultVerifier.h b/velox/exec/fuzzer/TransformResultVerifier.h index 15776275103b1..cccc45b379957 100644 --- a/velox/exec/fuzzer/TransformResultVerifier.h +++ b/velox/exec/fuzzer/TransformResultVerifier.h @@ -65,10 +65,20 @@ class TransformResultVerifier : public ResultVerifier { return assertEqualResults({transform(result)}, {transform(altResult)}); } + bool compare(const VectorPtr& result, const VectorPtr& altResult) override { + return assertEqualResults( + {transform(castToRowVector(result))}, + {transform(castToRowVector(altResult))}); + } + bool verify(const RowVectorPtr& /*result*/) override { VELOX_UNSUPPORTED(); } + bool verify(const VectorPtr& /*result*/) override { + VELOX_UNSUPPORTED(); + } + void reset() override { projections_.clear(); } @@ -80,6 +90,16 @@ class TransformResultVerifier : public ResultVerifier { return AssertQueryBuilder(plan).copyResults(data->pool()); } + RowVectorPtr castToRowVector(const VectorPtr& input) { + auto rowVector = std::make_shared( + input->pool(), + ROW({input->type()}), + nullptr, + 1, + std::vector{input}); + return rowVector; + } + const std::string transform_; std::vector projections_;