clintropolis opened a new pull request #10370:
URL: https://github.com/apache/druid/pull/10370
### Description
This PR adds the ability to compute the output type for a given expression,
given the types of the input bindings. It is worth mentioning that _nothing is
currently using or taking advantage of this_, and that this PR is scaffolding
for follow-up work which will introduce vectorized expressions (and could
potentially be used to optimize non-vectorized expressions as well).
Anyway, the main changes in this PR have been added to `Expr`:
```java
@Nullable
ExprType getOutputType(InputBindingTypes inputTypes);
interface InputBindingTypes
{
@Nullable
ExprType getType(String name);
}
```
with similar methods added to `Function` and `ApplyFunction` so that the
output types of functions can be computed.
I think there is a lot of room for further improvement, for example this
could potentially be combined with the input analysis, or maybe be transitioned
into a sort of `optimize` call that can potentially produce a new `Expr` which
already knows its output type, allowing for a `ExprType getOutputType()` with
no arguments. Some of the function abstract classes feel a bit messy as well,
however, I leave all that as work for another day.
It also includes a minor refactor salvaged from #10355 for shorthand of
producing long typed boolean values.
<hr>
This PR has:
- [ ] been self-reviewed.
- [ ] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked
related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in
[licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml)
- [ ] added comments explaining the "why" and the intent of the code
wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths,
ensuring the threshold for [code
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
<hr>
##### Key changed/added classes in this PR
* `Expr`
* `ExprType`
* all implementations of `Expr`, `Function`, and `ApplyFunction` can now
produce type information.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]