renatocron commented on issue #12620:
URL: https://github.com/apache/druid/issues/12620#issuecomment-1150631395

   I was not able to reproduce the issue with the wikipedia datasource, even 
when re-importing multiple times to have lot of segments.
   
   the original query I was doing was:
   (select X where the conditions matched the MyFavCitiesFirst)
   union all 
   (select 2 where the conds matched other rules)
   
   but for some uses, the first query must should be disabled, so I did the 
same work-arround I usually do (use some bind to enable/disable the conditions, 
usually calcite optimizes this for no-op)
   
   but with this query and datasource I have, I got this exception:
   ```
    2022-06-09T03:24:33,879 WARN [sql[a50ad38f-265e-4115-96be-b4826c95ca86]] 
org.apache.druid.sql.http.SqlResource - Failed to handle query: 
SqlQuery{query='( 
    SELECT  
          CONCAT(dim_xpto,''), 
        MAX("last_seen") as last_seen 
    FROM datasource 
    WHERE  
        __time >= CURRENT_TIMESTAMP - INTERVAL '7' DAY  
        AND  
        (  
              1 = -1  -- dynamically disabling this query
        )  
    GROUP BY  
        1 
    ORDER BY last_seen DESC  
     
    LIMIT 1  
     ) 
    UNION ALL 
    ( 
    SELECT  
        CONCAT(dim_xpto,''), 
         
        MAX("last_seen") as last_seen 
    FROM datasource 
    WHERE  
        __time >= CURRENT_TIMESTAMP - INTERVAL '7' DAY  
      
    GROUP BY  
        1 
    ORDER BY last_seen DESC  
    LIMIT 1  
    )', resultFormat=array, header=true, context={sqlOuterLimit=101}, 
parameters=[]} 
    org.apache.calcite.plan.RelOptPlanner$CannotPlanException: There are not 
enough rules to produce a node with desired properties: convention=DRUID, 
sort=[]. 
    Missing conversion is LogicalSort[convention: NONE -> DRUID] 
    There is 1 empty subset: rel#140371:Subset#11.DRUID.[], the relevant part 
of the original plan is as follows 
    140369:LogicalSort(fetch=[101]) 
      140367:LogicalUnion(subset=[rel#140368:Subset#10.NONE.[]], all=[true]) 
        140350:LogicalProject(subset=[rel#140382:Subset#1.NONE.[1 DESC]], 
EXPR$0=[CONCAT($2, '')], last_seen=[$1]) 
          140314:LogicalValues(subset=[rel#140349:Subset#0.NONE.[]], 
tuples=[[]]) 
        140365:LogicalSort(subset=[rel#140366:Subset#9.NONE.[1 DESC]], 
sort0=[$1], dir0=[DESC], fetch=[1]) 
          140363:LogicalAggregate(subset=[rel#140364:Subset#8.NONE.[]], 
group=[{0}], last_seen=[MAX($1)]) 
            140361:LogicalProject(subset=[rel#140362:Subset#7.NONE.[]], 
EXPR$0=[CONCAT($2, '')], last_seen=[$1]) 
              140359:LogicalFilter(subset=[rel#140360:Subset#6.NONE.[]], 
condition=[>=($0, 2022-06-02 03:24:33)]) 
                140357:LogicalProject(subset=[rel#140358:Subset#5.NONE.[]], 
__time=[$0], last_seen=[$6], dim_xpto=[$7]) 
                  140283:LogicalTableScan(subset=[rel#140356:Subset#4.NONE.[]], 
table=[[druid, datasource]]) 
     
    Root: rel#140371:Subset#11.DRUID.[] 
    Original rel: 
   ```
   I'll try to make a dataset to reproduce this, but at the moment I'm too busy 
to debug this further, it's easier to just use the order-by version above with 
the list work-arround, or change the query on the code instead of using the 
bind to disable portions of it


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