Skip to content

Commit

Permalink
Add Spark runner type
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo committed Aug 19, 2024
1 parent 62db265 commit b5159f4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion velox/exec/fuzzer/ReferenceQueryRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ReferenceQueryRunner {

virtual ~ReferenceQueryRunner() = default;

enum class RunnerType { kPrestoQueryRunner, kDuckQueryRunner };
enum class RunnerType { kPrestoQueryRunner, kDuckQueryRunner, kSparkQueryRunner };

virtual RunnerType runnerType() const = 0;

Expand Down
17 changes: 17 additions & 0 deletions velox/functions/sparksql/fuzzer/SparkQueryRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ void writeToFile(

} // namespace

const std::vector<TypePtr>& SparkQueryRunner::supportedScalarTypes() const {
static const std::vector<TypePtr> kScalarTypes{
BOOLEAN(),
TINYINT(),
SMALLINT(),
INTEGER(),
BIGINT(),
REAL(),
DOUBLE(),
VARCHAR(),
VARBINARY(),
TIMESTAMP(),
DATE(),
};
return kScalarTypes;
}

std::optional<std::string> SparkQueryRunner::toSql(
const velox::core::PlanNodePtr& plan) {
if (const auto aggregationNode =
Expand Down
6 changes: 6 additions & 0 deletions velox/functions/sparksql/fuzzer/SparkQueryRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class SparkQueryRunner : public velox::exec::test::ReferenceQueryRunner {
pool_(rootPool->addLeafChild("leaf")),
copyPool_(rootPool->addLeafChild("copy")) {};

RunnerType runnerType() const override {
return RunnerType::kSparkQueryRunner;
}

const std::vector<TypePtr>& supportedScalarTypes() const override;

/// Converts Velox query plan to Spark SQL. Supports Values -> Aggregation.
/// Values node is converted into reading from 'tmp' table.
/// @return std::nullopt for unsupported cases.
Expand Down

0 comments on commit b5159f4

Please sign in to comment.