add EVAL function to run arbitrary native expressions in SQL
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 😅 Because of this, it is disabled unless sqlAllowEval is set to true on the query context.
This PR has:
- [ ] been self-reviewed.
- [ ] using the concurrency checklist (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
- [ ] 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 is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
i do find the branch name quite intriguing.
i do find the branch name quite intriguing.
Heh, the branch name captures my hesitation to add something like this 😅, which is why it is gated behind a query context flag. This should probably never be anyones first choice to use in day to day querying. Rather, I imagine this as a sort of escape hatch, with a small number of legitimate uses being workarounds for issues with translating SQL to native queries and to expose native expressions which have not yet been wired up to SQL.
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the [email protected] list. Thank you for your contributions.
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the [email protected] list. Thank you for your contributions.
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the [email protected] list. Thank you for your contributions.
This pull request/issue has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.