Green-Angry-Bird opened a new issue #10221:
URL: https://github.com/apache/druid/issues/10221


   ### Description
   
   A very unhelpful `Unknown exception (org.apache.druid.java.util.common.ISE): 
Cannot build plan for query` is returned when the projection of a subquery 
containing a union has a different columnar order.
   
   Sample query:
   ```
   SELECT airline, purchase_timestamp FROM (
       SELECT 
           "__time" as purchase_timestamp,
           "Airline" as airline
       FROM "book" 
       UNION ALL
       SELECT 
           "__time" as purchase_timestamp,
           "Airline" as airline
       FROM  "avail"
   )
   ```
   
   The above query fails since airline, purchase_timestamp is in a different 
order than the subquery. There is a corresponding error in the broker log 
(truncated for brevity):
   ```
   org.apache.druid.sql.http.SqlResource - Failed to handle query: [...]
   org.apache.calcite.plan.RelOptPlanner$CannotPlanException: There are not 
enough rules to produce a node with desired properties: [...]
   Suppressed: org.apache.calcite.plan.RelOptPlanner$CannotPlanException: There 
are not enough rules to produce a node with desired properties: 
convention=BINDABLE, sort=[]. All the inputs have relevant nodes, however the 
cost is still infinite [...]
   ```
   
   The following query works (projection is in the SAME order as union 
subquery):
   ```
   SELECT purchase_timestamp, airline FROM (
       SELECT 
           "__time" as purchase_timestamp,
           "Airline" as airline
       FROM "book" 
       UNION ALL
       SELECT 
           "__time" as purchase_timestamp,
           "Airline" as airline
       FROM  "avail"
   )
   ```
   
   The following query also works (projection is in a different order but 
subquery is NOT a union):
   ```
   SELECT airline, purchase_timestamp FROM (
       SELECT 
           "__time" as purchase_timestamp,
           "Airline" as airline
       FROM "book"
   )
   ```
   
   ### Affected Version
   
   We are running 0.18.0
   
   
   


----------------------------------------------------------------
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]

Reply via email to