Skip to content

Commit

Permalink
Pass input types to SimpleFunctionAdapterFactory::createVectorFunction (
Browse files Browse the repository at this point in the history
facebookincubator#9120)

Summary:

This change is part of enabling simple functions to process inputs of decimal type. Such processing requires access to decimal type parameters (precision and scale). This change provides full type information to the function constructor. A follow-up change will pass this to simple function's 'initialize' method.

See facebookincubator#9096 for the end-to-end workflow.

Differential Revision: D55011267
  • Loading branch information
mbasmanova authored and facebook-github-bot committed Mar 18, 2024
1 parent 90a9dbb commit de4bfaf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions velox/expression/ExprCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,12 @@ ExprPtr compileRewrittenExpression(
simpleFunctionEntry->type(),
resultType,
folly::join(", ", inputTypes));
auto func_2 = simpleFunctionEntry->createFunction()->createVectorFunction(
getConstantInputs(compiledInputs), config);
auto func = simpleFunctionEntry->createFunction()->createVectorFunction(
inputTypes, getConstantInputs(compiledInputs), config);
result = std::make_shared<Expr>(
resultType,
std::move(compiledInputs),
std::move(func_2),
std::move(func),
call->name(),
trackCpuUsage);
} else {
Expand Down
6 changes: 4 additions & 2 deletions velox/expression/SimpleFunctionAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ class SimpleFunctionAdapter : public VectorFunction {
}

public:
explicit SimpleFunctionAdapter(
SimpleFunctionAdapter(
const std::vector<TypePtr>& /*inputTypes*/,
const core::QueryConfig& config,
const std::vector<VectorPtr>& constantInputs)
: fn_{std::make_unique<FUNC>()} {
Expand Down Expand Up @@ -901,10 +902,11 @@ class SimpleFunctionAdapterFactoryImpl : public SimpleFunctionAdapterFactory {
explicit SimpleFunctionAdapterFactoryImpl() {}

std::unique_ptr<VectorFunction> createVectorFunction(
const std::vector<TypePtr>& inputTypes,
const std::vector<VectorPtr>& constantInputs,
const core::QueryConfig& config) const override {
return std::make_unique<SimpleFunctionAdapter<UDFHolder>>(
config, constantInputs);
inputTypes, config, constantInputs);
}
};

Expand Down
1 change: 1 addition & 0 deletions velox/expression/VectorFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class ApplyNeverCalled final : public VectorFunction {
class SimpleFunctionAdapterFactory {
public:
virtual std::unique_ptr<VectorFunction> createVectorFunction(
const std::vector<TypePtr>& inputTypes,
const std::vector<VectorPtr>& constantInputs,
const core::QueryConfig& config) const = 0;
virtual ~SimpleFunctionAdapterFactory() = default;
Expand Down
2 changes: 1 addition & 1 deletion velox/expression/tests/SimpleFunctionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ VectorPtr testVariadicArgReuse(
exec::simpleFunctions()
.resolveFunction(functionName, {})
->createFunction()
->createVectorFunction({}, execCtx->queryCtx()->queryConfig());
->createVectorFunction({}, {}, execCtx->queryCtx()->queryConfig());

// Create a dummy EvalCtx.
SelectivityVector rows(inputs[0]->size());
Expand Down

0 comments on commit de4bfaf

Please sign in to comment.