Skip to content

Commit

Permalink
Support Spark query runner
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo committed Apr 25, 2024
1 parent 28a1f18 commit f5dcf32
Show file tree
Hide file tree
Showing 26 changed files with 5,317 additions and 389 deletions.
955 changes: 955 additions & 0 deletions CMake/Findgrpc.cmake

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions velox/exec/fuzzer/AggregationFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ namespace facebook::velox::exec::test {
class AggregationFuzzerBase;

namespace {
namespace {
bool isSupportedDwrfType(const TypePtr& type) {
if (type->isDate() || type->isIntervalDayTime() || type->isUnKnown()) {
return false;
}

for (auto i = 0; i < type->size(); ++i) {
if (!isSupportedDwrfType(type->childAt(i))) {
return false;
}
}

return true;
}
} // namespace

class AggregationFuzzer : public AggregationFuzzerBase {
public:
Expand Down Expand Up @@ -1067,8 +1082,8 @@ bool AggregationFuzzer::compareEquivalentPlanResults(
LOG(INFO) << "Verified results against reference DB";
}
} else if (referenceQueryRunner_->supportsVeloxVectorResults()) {
if (isSupportedType(firstPlan->outputType()) &&
isSupportedType(input.front()->type())) {
if (isSupportedDwrfType(firstPlan->outputType()) &&
isSupportedDwrfType(input.front()->type())) {
auto referenceResult =
computeReferenceResultsAsVector(firstPlan, input);
stats_.updateReferenceQueryStats(referenceResult.second);
Expand Down
19 changes: 2 additions & 17 deletions velox/exec/fuzzer/AggregationFuzzerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,6 @@ int32_t AggregationFuzzerBase::randInt(int32_t min, int32_t max) {
return boost::random::uniform_int_distribution<int32_t>(min, max)(rng_);
}

bool AggregationFuzzerBase::isSupportedType(const TypePtr& type) const {
// Date / IntervalDayTime/ Unknown are not currently supported by DWRF.
if (type->isDate() || type->isIntervalDayTime() || type->isUnKnown()) {
return false;
}

for (auto i = 0; i < type->size(); ++i) {
if (!isSupportedType(type->childAt(i))) {
return false;
}
}

return true;
}

bool AggregationFuzzerBase::addSignature(
const std::string& name,
const FunctionSignaturePtr& signature) {
Expand Down Expand Up @@ -467,7 +452,7 @@ AggregationFuzzerBase::computeReferenceResults(
sql.value(), input, plan->outputType()),
ReferenceQueryErrorCode::kSuccess);
} catch (...) {
LOG(WARNING) << "Query failed in the reference DB";
LOG(WARNING) << "Query failed in the reference DB: " << sql.value();
return std::make_pair(
std::nullopt, ReferenceQueryErrorCode::kReferenceQueryFail);
}
Expand All @@ -493,7 +478,7 @@ AggregationFuzzerBase::computeReferenceResultsAsVector(
sql.value(), input, plan->outputType()),
ReferenceQueryErrorCode::kSuccess);
} catch (...) {
LOG(WARNING) << "Query failed in the reference DB";
LOG(WARNING) << "Query failed in the reference DB: " << sql.value();
return std::make_pair(
std::nullopt, ReferenceQueryErrorCode::kReferenceQueryFail);
}
Expand Down
6 changes: 0 additions & 6 deletions velox/exec/fuzzer/AggregationFuzzerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ class AggregationFuzzerBase {
const std::vector<std::shared_ptr<ResultVerifier>>& customVerifiers,
const velox::test::ResultOrError& expected);

/// Returns false if the type or its children are unsupported.
/// Currently returns false if type is Date,IntervalDayTime or Unknown.
/// @param type
/// @return bool
bool isSupportedType(const TypePtr& type) const;

// @param customVerification If false, results are compared as is. Otherwise,
// only row counts are compared.
// @param customVerifiers Custom verifier for each aggregate function. These
Expand Down
4 changes: 2 additions & 2 deletions velox/exec/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# 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.

add_library(velox_fuzzer_util DuckQueryRunner.cpp PrestoQueryRunner.cpp)
add_library(velox_fuzzer_util DuckQueryRunner.cpp PrestoQueryRunner.cpp
QueryTranslator.cpp)

target_link_libraries(velox_fuzzer_util velox_core velox_exec_test_lib cpr::cpr
velox_type_parser Folly::folly)
Expand Down
Loading

0 comments on commit f5dcf32

Please sign in to comment.