clintropolis opened a new pull request, #13336:
URL: https://github.com/apache/druid/pull/13336
### Description
This PR adds a new SQL function, `EVAL`, as a pass-through to run arbitrary
native Druid expressions. The SQL type inference is fully wired up to the
native expression type inference, so any native expression which correct
reports its type should be able to be correctly validated in the SQL layer. The
syntax is to supply the expression as a string literal and then all of the
identifiers to use as input arguments following it.
```
SELECT
EVAL('m1 + m2', m1, m2),
EVAL('concat(dim1, ''hello'', dim2)', dim1, dim2),
EVAL('to_json_string(dim1)', dim1)
FROM druid.foo
```
The input arguments are included so that the type inference can function, as
it allows us to construct a map of identifier to type which can then be used to
construct the native `Expr.InputBindingInspector` to run the type inference.
I have elected not to document this functionality at this time because I'm
not sure if we should encourage using this heavily, but it does seem like a
handy tool to have available 😅
<hr>
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency
checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md)
(Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] 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/dev/license.md)
- [ ] 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.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]