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

Extend ApproxPercentileResultVerifier for window fuzzer #10367

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions velox/exec/fuzzer/FuzzerUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once

#include "velox/core/PlanNode.h"
#include "velox/exec/Split.h"

namespace facebook::velox::exec::test {
const std::string kHiveConnectorId = "test-hive";

struct SortingKeyAndOrder {
const std::string key_;
const core::SortOrder sortOrder_;

SortingKeyAndOrder(std::string key, core::SortOrder sortOrder)
: key_(std::move(key)), sortOrder_(std::move(sortOrder)) {}
};

/// Write the vector to the path.
void writeToFile(
const std::string& path,
Expand Down
2 changes: 2 additions & 0 deletions velox/exec/fuzzer/ResultVerifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <string>

#include "velox/core/PlanNode.h"
#include "velox/exec/fuzzer/FuzzerUtil.h"
#include "velox/vector/ComplexVector.h"

namespace facebook::velox::exec::test {
Expand Down Expand Up @@ -61,6 +62,7 @@ class ResultVerifier {
virtual void initializeWindow(
const std::vector<RowVectorPtr>& /*input*/,
const std::vector<std::string>& /*partitionByKeys*/,
const std::vector<SortingKeyAndOrder>& /*sortingKeysAndOrders*/,
const core::WindowNode::Function& /*function*/,
const std::string& /*frame*/,
const std::string& /*windowName*/) {
Expand Down
19 changes: 15 additions & 4 deletions velox/exec/fuzzer/WindowFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ std::string WindowFuzzer::getFrame(
return frame.str();
}

std::vector<WindowFuzzer::SortingKeyAndOrder>
WindowFuzzer::generateSortingKeysAndOrders(
std::vector<SortingKeyAndOrder> WindowFuzzer::generateSortingKeysAndOrders(
const std::string& prefix,
std::vector<std::string>& names,
std::vector<TypePtr>& types) {
Expand Down Expand Up @@ -359,11 +358,17 @@ void initializeVerifier(
const std::shared_ptr<ResultVerifier>& customVerifier,
const std::vector<RowVectorPtr>& input,
const std::vector<std::string>& partitionKeys,
const std::vector<SortingKeyAndOrder>& sortingKeysAndOrders,
const std::string& frame) {
const auto& windowNode =
std::dynamic_pointer_cast<const core::WindowNode>(plan);
customVerifier->initializeWindow(
input, partitionKeys, windowNode->windowFunctions()[0], frame, "w0");
input,
partitionKeys,
sortingKeysAndOrders,
windowNode->windowFunctions()[0],
frame,
"w0");
}
} // namespace

Expand Down Expand Up @@ -424,7 +429,13 @@ bool WindowFuzzer::verifyWindow(
VELOX_CHECK(
customVerifier->supportsVerify(),
"Window fuzzer only uses custom verify() methods.");
initializeVerifier(plan, customVerifier, input, partitionKeys, frame);
initializeVerifier(
plan,
customVerifier,
input,
partitionKeys,
sortingKeysAndOrders,
frame);
customVerifier->verify(resultOrError.result);
}
}
Expand Down
9 changes: 1 addition & 8 deletions velox/exec/fuzzer/WindowFuzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "velox/exec/Aggregate.h"
#include "velox/exec/WindowFunction.h"
#include "velox/exec/fuzzer/AggregationFuzzerBase.h"
#include "velox/exec/fuzzer/FuzzerUtil.h"
#include "velox/exec/fuzzer/PrestoQueryRunner.h"
#include "velox/exec/fuzzer/ReferenceQueryRunner.h"
#include "velox/vector/fuzzer/VectorFuzzer.h"
Expand Down Expand Up @@ -76,14 +77,6 @@ class WindowFuzzer : public AggregationFuzzerBase {
void go(const std::string& planPath);

private:
struct SortingKeyAndOrder {
const std::string key_;
const core::SortOrder sortOrder_;

SortingKeyAndOrder(std::string key, core::SortOrder sortOrder)
: key_(std::move(key)), sortOrder_(std::move(sortOrder)) {}
};

void addWindowFunctionSignatures(const WindowFunctionMap& signatureMap);

// Return a randomly generated frame clause string together with a boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ApproxDistinctResultVerifier : public ResultVerifier {
void initializeWindow(
const std::vector<RowVectorPtr>& input,
const std::vector<std::string>& partitionByKeys,
const std::vector<SortingKeyAndOrder>& /*sortingKeysAndOrders*/,
const core::WindowNode::Function& function,
const std::string& frame,
const std::string& windowName) override {
Expand Down
Loading
Loading