Skip to content
Open
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/experimental/cudf/exec/ToCudf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ bool CompileState::compile(bool allowCpuFallback) {

// Check projects separately.
if (projectPlanNode) {
if (projectPlanNode->sources()[0]->outputType()->size() == 0 ||
projectPlanNode->outputType()->size() == 0) {
return false;
}
if (!canBeEvaluatedByCudf(
projectPlanNode->projections(), ctx->task->queryCtx().get())) {
return false;
Expand All @@ -155,6 +159,12 @@ bool CompileState::compile(bool allowCpuFallback) {
return false;
}

if (aggregationPlanNode->sources()[0]->outputType()->size() == 0) {
// We cannot hande RowVectors with a length but no data.
// This is the case with count(*) global (without groupby)
return false;
}

// Use the centralized canBeEvaluatedByCudf function which includes
// expression expansion
return canBeEvaluatedByCudf(
Expand Down
16 changes: 16 additions & 0 deletions velox/experimental/cudf/tests/AggregationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,22 @@ TEST_F(AggregationTest, avgPartialFinalGlobal) {
assertQuery(op, "SELECT avg(c1), avg(c2), avg(c4), avg(c5) FROM tmp");
}

TEST_F(AggregationTest, countStarGlobal) {
auto vectors = makeVectors(rowType_, 10, 100);

createDuckDbTable(vectors);

auto op = PlanBuilder()
.values(vectors)
.filter("c0 > 10")
.project({})
.partialAggregation({}, {"count(*)"})
.finalAggregation()
.planNode();

assertQuery(op, "SELECT count(*) FROM tmp WHERE c0 > 10");
}

TEST_F(AggregationTest, countSingleGroupBy) {
auto vectors = makeVectors(rowType_, 10, 100);
createDuckDbTable(vectors);
Expand Down
Loading