Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhli1142015 committed Dec 20, 2023
1 parent e9f7c7a commit aa2e3f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions velox/expression/tests/SimpleFunctionInitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ TEST_F(SimpleFunctionInitTest, initializationArray) {
NonDefaultWithArrayInitFunction,
Array<int32_t>,
int32_t,
Constant<Array<int32_t>>>({"non_default_behavior_with_init"});
Array<int32_t>>({"non_default_behavior_with_init"});

auto testFn =
[&](const std::optional<int32_t>& first,
Expand Down Expand Up @@ -166,7 +166,7 @@ TEST_F(SimpleFunctionInitTest, initializationMap) {
NonDefaultWithMapInitFunction,
int64_t,
int32_t,
Constant<Map<int32_t, int64_t>>>({"non_default_behavior_with_map_init"});
Map<int32_t, int64_t>>({"non_default_behavior_with_map_init"});

auto mapVectorPtr = makeMapVector<int32_t, int64_t>(
1,
Expand Down
25 changes: 15 additions & 10 deletions velox/expression/tests/SimpleFunctionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,44 +1243,49 @@ TEST_F(SimpleFunctionTest, flatNoNullsPathCallNullFree) {
testCallNullFreeSupportFlatNotNulls<Varchar, Varchar>(false, false);
}

namespace {
template <typename T>
struct ConstantArgumentFunction {
VELOX_DEFINE_FUNCTION_TYPES(T);

void initialize(
const core::QueryConfig& /*config*/,
const arg_type<int32_t>* /*first*/,
const arg_type<int32_t>* second,
const arg_type<Varchar>* third,
const arg_type<Generic<T1>>* fourth) {}
const arg_type<int32_t>* /*second*/,
const arg_type<Varchar>* /*third*/,
const arg_type<Generic<T1>>* /*fourth*/,
const arg_type<Array<int32_t>>* /*fifth*/,
const arg_type<Map<int32_t, int32_t>>* /*sixth*/) {}

bool callNullable(
out_type<int64_t>& out,
const arg_type<int32_t>* first,
const arg_type<int32_t>* /*first*/,
const arg_type<int32_t>* /*second*/,
const arg_type<Varchar>* /*third*/,
const arg_type<Generic<T1>>* /*fourth*/) {
out = 0;
const arg_type<Generic<T1>>* /*fourth*/,
const arg_type<Array<int32_t>>* /*fifth*/,
const arg_type<Map<int32_t, int32_t>>* /*sixth*/) {
out = 1;
return true;
}
};

} // namespace

TEST_F(SimpleFunctionTest, constantArgument) {
registerFunction<
ConstantArgumentFunction,
int64_t,
int32_t,
Constant<int32_t>,
Constant<Varchar>,
Constant<Generic<T1>>>({"constant_argument_function"});
Constant<Generic<T1>>,
Constant<Array<int32_t>>,
Constant<Map<int32_t, int32_t>>>({"constant_argument_function"});
auto signatures = exec::simpleFunctions().getFunctionSignatures(
"constant_argument_function");
EXPECT_FALSE(signatures[0]->constantArguments().at(0));
EXPECT_TRUE(signatures[0]->constantArguments().at(1));
EXPECT_TRUE(signatures[0]->constantArguments().at(2));
EXPECT_TRUE(signatures[0]->constantArguments().at(3));
EXPECT_TRUE(signatures[0]->constantArguments().at(4));
EXPECT_TRUE(signatures[0]->constantArguments().at(5));
}
} // namespace

0 comments on commit aa2e3f2

Please sign in to comment.