Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yma11 committed Apr 29, 2024
1 parent 758c372 commit bd5ebc7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ object VeloxIntermediateData {
def getRowConstructFuncName(aggFunc: AggregateFunction): String = aggFunc match {
case _: Average | _: Sum if aggFunc.dataType.isInstanceOf[DecimalType] =>
"row_constructor"
// For agg function min_by/max_by, it needs to keep rows with null value but non-null
// comparison, such as <null, 5>. So we set the struct to null when all of the arguments
// are null
case _: MaxMinBy =>
"row_constructor_with_all_null"
case _ => "row_constructor_with_null"
Expand Down
1 change: 0 additions & 1 deletion cpp/velox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ set(VELOX_SRCS
memory/VeloxMemoryManager.cc
operators/functions/RegistrationAllFunctions.cc
operators/functions/RowConstructorWithNull.cc
operators/functions/RowConstructorWithAllNull.cc
operators/functions/SparkTokenizer.cc
operators/serializer/VeloxColumnarToRowConverter.cc
operators/serializer/VeloxColumnarBatchSerializer.cc
Expand Down
63 changes: 0 additions & 63 deletions cpp/velox/operators/functions/RowConstructorWithAllNull.cc

This file was deleted.

17 changes: 5 additions & 12 deletions cpp/velox/operators/functions/RowConstructorWithAllNull.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,11 @@

#pragma once

#include "velox/expression/FunctionCallToSpecialForm.h"
#include "velox/expression/SpecialForm.h"
#include "RowConstructorWithNull.h"

namespace gluten {
class RowConstructorWithAllNullCallToSpecialForm : public facebook::velox::exec::FunctionCallToSpecialForm {
class RowConstructorWithAllNullCallToSpecialForm : public RowConstructorWithNullCallToSpecialForm {
public:
facebook::velox::TypePtr resolveType(const std::vector<facebook::velox::TypePtr>& argTypes) override;

facebook::velox::exec::ExprPtr constructSpecialForm(
const facebook::velox::TypePtr& type,
std::vector<facebook::velox::exec::ExprPtr>&& compiledChildren,
bool trackCpuUsage,
const facebook::velox::core::QueryConfig& config) override;

static constexpr const char* kRowConstructorWithAllNull = "row_constructor_with_all_null";

protected:
Expand All @@ -39,6 +30,8 @@ class RowConstructorWithAllNullCallToSpecialForm : public facebook::velox::exec:
const facebook::velox::TypePtr& type,
std::vector<facebook::velox::exec::ExprPtr>&& compiledChildren,
bool trackCpuUsage,
const facebook::velox::core::QueryConfig& config);
const facebook::velox::core::QueryConfig& config) {
return constructSpecialForm(kRowConstructorWithAllNull, type, std::move(compiledChildren), trackCpuUsage, config);
}
};
} // namespace gluten
10 changes: 6 additions & 4 deletions cpp/velox/operators/functions/RowFunctionWithNull.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RowFunctionWithNull final : public facebook::velox::exec::VectorFunction {
if (arg->mayHaveNulls() && arg->isNullAt(i)) {
// For row_constructor_with_null, if any argument of the struct is null,
// set the struct as null.
if (!allNull) {
if constexpr (!allNull) {
facebook::velox::bits::setNull(nullsPtr, i, true);
cntNull++;
break;
Expand All @@ -60,9 +60,11 @@ class RowFunctionWithNull final : public facebook::velox::exec::VectorFunction {
}
}
// For row_constructor_with_all_null, set the struct to be null when all arguments are all
if (allNull && argsNullCnt == argsCopy.size()) {
facebook::velox::bits::setNull(nullsPtr, i, true);
cntNull++;
if constexpr (allNull) {
if (argsNullCnt == argsCopy.size()) {
facebook::velox::bits::setNull(nullsPtr, i, true);
cntNull++;
}
}
}
});
Expand Down

0 comments on commit bd5ebc7

Please sign in to comment.