abhishekagarwal87 opened a new pull request #11911:
URL: https://github.com/apache/druid/pull/11911


   <!-- Thanks for trying to help us make Apache Druid be the best it can be! 
Please fill out as much of the following information as is possible (where 
relevant, and remove it when irrelevant) to help make the intention and scope 
of this PR clear in order to ease review. -->
   
   <!-- Please read the doc for contribution 
(https://github.com/apache/druid/blob/master/CONTRIBUTING.md) before making 
this PR. Also, once you open a PR, please _avoid using force pushes and 
rebasing_ since these make it difficult for reviewers to see what you've 
changed in response to their reviews. See [the 'If your pull request shows 
conflicts with master' 
section](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#if-your-pull-request-shows-conflicts-with-master)
 for more details. -->
   
   <!-- Replace XXXX with the id of the issue fixed in this PR. Remove this 
section if there is no corresponding issue. Don't reference the issue in the 
title of this pull-request. -->
   
   <!-- If you are a committer, follow the PR action item checklist for 
committers:
   
https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers.
 -->
   
   ### Description
   
   <!-- Describe the goal of this PR, what problem are you fixing. If there is 
a corresponding issue (referenced above), it's not necessary to repeat the 
description here, however, you may choose to keep one summary sentence. -->
   
   This PR does two things
    - It adds the capability to surface missing features in SQL to users - The 
calcite planner will explore through multiple rules to convert a logical SQL 
query to a druid native query. Some rules change the shape of the query itself, 
optimize it and some rules are responsible for translating the query into a 
druid native query. These are DruidQueryRule, DruidOuterQueryRule, 
DruidJoinRule, DruidUnionDataSourceRule, DruidUnionRule etc. These rules will 
look at SQL and will do the necessary transformation. But if the rule can't 
transform the query, it returns back the control to the calcite planner without 
recording why was it not able to transform. E.g. there is a join query with a 
non-equal join condition. DruidJoinRule will look at the condition, see that it 
is not supported, and return back the control. The reason can be that a query 
can be planned in many different ways so if one rule can't parse it, the query 
may still be parseable by other rules. In this PR, we are intercepting
  these gaps and passing them back to the user if the query could not be 
planned at all. 
    - The said capability has been used to generate actionable errors for some 
common unsupported SQL features. However, not all possible errors are covered 
and we can keep adding more in the future. 
    
   The code changes themselves are not intrusive and minimal. I have modified 
the `PlannerContext` to record any planning error and then use it when 
generating a user-facing exception. 
   
   
   ##### Key changed/added classes in this PR
    * `DruidPlanner`
    * `Druid*Rule`
    * `DruidUnionDataSourceRel`
   
   <hr>
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not 
all of these items apply to every PR. Remove the items which are not done or 
not relevant to the PR. None of the items from the checklist below are strictly 
necessary, but it would be very helpful if you at least self-review the PR. -->
   
   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/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]

Reply via email to