-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add PrestoQueryRunner #7628
Closed
Closed
Add PrestoQueryRunner #7628
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <folly/init/Init.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include "velox/exec/tests/utils/AssertQueryBuilder.h" | ||
#include "velox/exec/tests/utils/PlanBuilder.h" | ||
#include "velox/exec/tests/utils/PrestoQueryRunner.h" | ||
#include "velox/functions/prestosql/aggregates/RegisterAggregateFunctions.h" | ||
#include "velox/functions/prestosql/registration/RegistrationFunctions.h" | ||
#include "velox/parse/TypeResolver.h" | ||
#include "velox/vector/tests/utils/VectorTestBase.h" | ||
|
||
using namespace facebook::velox; | ||
using namespace facebook::velox::test; | ||
|
||
namespace facebook::velox::exec::test { | ||
|
||
class PrestoQueryRunnerTest : public ::testing::Test, | ||
public velox::test::VectorTestBase { | ||
protected: | ||
void SetUp() override { | ||
velox::functions::prestosql::registerAllScalarFunctions(); | ||
velox::aggregate::prestosql::registerAllAggregateFunctions(); | ||
velox::parse::registerTypeResolver(); | ||
} | ||
}; | ||
|
||
TEST_F(PrestoQueryRunnerTest, DISABLED_basic) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you add a comment here that this is disabled because it requires a presto co-ordinator running at localhost etc ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added comments. |
||
auto queryRunner = std::make_unique<PrestoQueryRunner>( | ||
"http://127.0.0.1:8080", "hive", 20'000); | ||
|
||
auto results = queryRunner->execute("SELECT count(*) FROM nation"); | ||
auto expected = makeRowVector({ | ||
makeConstant<int64_t>(25, 1), | ||
}); | ||
velox::exec::test::assertEqualResults({expected}, {results}); | ||
|
||
results = | ||
queryRunner->execute("SELECT regionkey, count(*) FROM nation GROUP BY 1"); | ||
|
||
expected = makeRowVector({ | ||
makeFlatVector<int64_t>({0, 1, 2, 3, 4}), | ||
makeFlatVector<int64_t>({5, 5, 5, 5, 5}), | ||
}); | ||
velox::exec::test::assertEqualResults({expected}, {results}); | ||
} | ||
|
||
TEST_F(PrestoQueryRunnerTest, DISABLED_fuzzer) { | ||
auto data = makeRowVector({ | ||
makeFlatVector<int64_t>({1, 2, 3, 4, 5}), | ||
makeArrayVectorFromJson<int64_t>({ | ||
"[]", | ||
"[1, 2, 3]", | ||
"null", | ||
"[1, 2, 3, 4]", | ||
}), | ||
}); | ||
|
||
auto plan = velox::exec::test::PlanBuilder() | ||
.values({data}) | ||
.singleAggregation({}, {"min(c0)", "max(c0)", "set_agg(c1)"}) | ||
.project({"a0", "a1", "array_sort(a2)"}) | ||
.planNode(); | ||
|
||
auto queryRunner = | ||
std::make_unique<PrestoQueryRunner>("http://127.0.0.1:8080", "hive"); | ||
auto sql = queryRunner->toSql(plan); | ||
ASSERT_TRUE(sql.has_value()); | ||
|
||
auto prestoResults = queryRunner->execute( | ||
sql.value(), | ||
{data}, | ||
ROW({"a", "b", "c"}, {BIGINT(), BIGINT(), ARRAY(BIGINT())})); | ||
|
||
auto veloxResults = | ||
velox::exec::test::AssertQueryBuilder(plan).copyResults(pool()); | ||
velox::exec::test::assertEqualResults( | ||
prestoResults, plan->outputType(), {veloxResults}); | ||
} | ||
} // namespace facebook::velox::exec::test | ||
|
||
int main(int argc, char** argv) { | ||
testing::InitGoogleTest(&argc, argv); | ||
folly::Init init(&argc, &argv, true); | ||
return RUN_ALL_TESTS(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a separate executable for his test? We used to have a problem with CI ran out of disk space because all these executables are very large. CC: @kgpai
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbasmanova Removed this executable, and linked the runner test into
velox_exec_infra_test
.