[C++] Can InputType support nested types in the future?
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
## 1.our problem
we have a kernel, input is struct array, such as struct, When registering the kernel, in order to distinguish between `struct` and `struct` (means: sum column is decimal128 or decimal256), we need to use TypeMatcher to match one.
for example:
```cpp
Status Visit(const Decimal128Type&) {
kernel = MakeKernel(std::move(InputType(match::AvgFinalDecimal128(), ValueDescr::ARRAY)),
AvgSumInit>);
return Status::OK();
}
Status Visit(const Decimal256Type&) {
kernel = MakeKernel(std::move(InputType(match::AvgFinalDecimal256(), ValueDescr::ARRAY)),
AvgSumInit>);
return Status::OK();
}
```
Take `AvgFinalDecimal128` for example:
```cpp
class AvgFinalDecimal128Matcher : public TypeMatcher {
public:
AvgFinalDecimal128Matcher() {}
bool Matches(const DataType& type) const override {
if (type.id() != Type::STRUCT) {
return false;
}
return (type.fields()[0])->type()->id() == Type::DECIMAL128;
}
//......
}
```
In the current code, we need to write two matchers. In fact, we can simplify it to a matcher (the input is a struct input by the user), but currently TypeMatcher does not support input. The constructor is as follows:
```
InputType(std::shared_ptr type_matcher) {}
```
It does not support passing parameters, so will it be possible to support extended parameters in the future?
### Component(s)
C++
Contributor guide
Research direction
Start by reading the InputType and TypeMatcher APIs referenced in the issue, then trace how nested struct types are currently matched. Compare the duplicated Decimal128 and Decimal256 matchers with the proposed parameterized approach. The issue does not define an implementation or acceptance criteria, so done would require an agreed API design and scope before coding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100