Skip to content

Commit

Permalink
Allow ExpressionRunnerTest to run with PrestoQueryRunner (facebookinc…
Browse files Browse the repository at this point in the history
…ubator#11254)

Summary:
Pull Request resolved: facebookincubator#11254

This is for facebookincubator#10308.

Reviewed By: kevinwilfong, xiaoxmeng

Differential Revision: D64359866

fbshipit-source-id: 031aa4de40b2969901c605d97d23506fff5f0490
  • Loading branch information
kagamiori authored and facebook-github-bot committed Oct 25, 2024
1 parent b2c7446 commit 9784f22
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions velox/expression/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ target_link_libraries(
velox_fuzzer_util
velox_exec_test_lib
velox_function_registry
velox_file
velox_hive_connector
velox_fuzzer_util
GTest::gtest
GTest::gtest_main)

Expand Down
37 changes: 36 additions & 1 deletion velox/expression/tests/ExpressionRunnerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@
#include <gflags/gflags.h>
#include <gtest/gtest.h>
#include "velox/common/base/Fs.h"
#include "velox/common/file/FileSystems.h"
#include "velox/connectors/hive/HiveConnector.h"
#include "velox/dwio/dwrf/RegisterDwrfWriter.h"
#include "velox/exec/fuzzer/FuzzerUtil.h"
#include "velox/exec/fuzzer/PrestoQueryRunner.h"
#include "velox/exec/fuzzer/ReferenceQueryRunner.h"
#include "velox/expression/tests/ExpressionVerifier.h"
#include "velox/functions/prestosql/aggregates/RegisterAggregateFunctions.h"
#include "velox/functions/prestosql/registration/RegistrationFunctions.h"
#include "velox/functions/sparksql/Register.h"
#include "velox/vector/VectorSaver.h"

using namespace facebook::velox;
using facebook::velox::exec::test::PrestoQueryRunner;
using facebook::velox::test::ReferenceQueryRunner;

DEFINE_string(
Expand Down Expand Up @@ -98,6 +103,19 @@ DEFINE_bool(
" were the same between the vectors then the buffers can simply be shared"
" between them instead.");

DEFINE_string(
reference_db_url,
"",
"ReferenceDB URI along with port. If set, we use the reference DB as the "
"source of truth. Otherwise, use Velox simplified eval path. Example: "
"--reference_db_url=http://127.0.0.1:8080");

DEFINE_uint32(
req_timeout_ms,
10000,
"Timeout in milliseconds for HTTP requests made to reference DB, "
"such as Presto. Example: --req_timeout_ms=2000");

static bool validateMode(const char* flagName, const std::string& value) {
static const std::unordered_set<std::string> kModes = {
"common", "simplified", "verify", "query"};
Expand Down Expand Up @@ -221,7 +239,24 @@ int main(int argc, char** argv) {
}

memory::initializeMemoryManager({});

filesystems::registerLocalFileSystem();
connector::registerConnectorFactory(
std::make_shared<connector::hive::HiveConnectorFactory>());
exec::test::registerHiveConnector({});
dwrf::registerDwrfWriterFactory();

std::shared_ptr<facebook::velox::memory::MemoryPool> rootPool{
facebook::velox::memory::memoryManager()->addRootPool()};
std::shared_ptr<ReferenceQueryRunner> referenceQueryRunner{nullptr};
if (FLAGS_registry == "presto" && !FLAGS_reference_db_url.empty()) {
referenceQueryRunner = std::make_shared<PrestoQueryRunner>(
rootPool.get(),
FLAGS_reference_db_url,
"expression_runner_test",
static_cast<std::chrono::milliseconds>(FLAGS_req_timeout_ms));
LOG(INFO) << "Using Presto as the reference DB.";
}

test::ExpressionRunner::run(
FLAGS_input_path,
Expand Down

0 comments on commit 9784f22

Please sign in to comment.