Brimborion opened a new issue, #14199:
URL: https://github.com/apache/druid/issues/14199

   ### Affected Version
   
   25.0.0
   
   ### Description
   
   Sometimes, when I create an SQL query with a AND clause referencing a lookup 
on the same column, I get an error or the native query cannot be created.
   
   This request is processed correctly:
   
   ```sql
   select isCompletedCasesLookup.k
   from lookup."30ef4a57-3647-4785-b7ca-9cbd568ae7c1-1_cases_is_completed" 
"isCompletedCasesLookup"
   where isCompletedCasesLookup.v = 'false' and isCompletedCasesLookup.v = 
'true'
   ```
   
   to this native query:
   
   ```json
   {
     "queryType": "scan",
     "dataSource": {
       "type": "inline",
       "columnNames": [
         "k",
         "v"
       ],
       "columnTypes": [
         "STRING",
         "STRING"
       ],
       "rows": []
     },
     "intervals": {
       "type": "intervals",
       "intervals": [
         "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"
       ]
     },
     "resultFormat": "compactedList",
     "columns": [
       "k"
     ],
     "legacy": false,
     "context": {
       "populateCache": false,
       "queryId": "e46be9e6-0686-4663-8fee-fd5c9b805708",
       "sqlQueryId": "e46be9e6-0686-4663-8fee-fd5c9b805708",
       "useApproximateCountDistinct": false,
       "useApproximateTopN": false,
       "useCache": false,
       "useNativeQueryExplain": true
     },
     "granularity": {
       "type": "all"
     }
   }
   ```
   
   But, when I try to run this query:
   
   ```sql
   select isCompletedCasesLookup.k
   from lookup."30ef4a57-3647-4785-b7ca-9cbd568ae7c1-1_cases_is_completed" 
"isCompletedCasesLookup"
   where lower(isCompletedCasesLookup.v) = 'false' and 
lower(isCompletedCasesLookup.v) = 'true'
   ```
   
   I get `java.lang.IllegalArgumentException` with message *Can only handle a 
single interval, got[[]]*. This is the native query generated:
   ```json
   {
     "queryType": "scan",
     "dataSource": {
       "type": "lookup",
       "lookup": "30ef4a57-3647-4785-b7ca-9cbd568ae7c1-1_cases_is_completed"
     },
     "intervals": {
       "type": "intervals",
       "intervals": []
     },
     "virtualColumns": [
       {
         "type": "expression",
         "name": "v0",
         "expression": "lower(\"v\")",
         "outputType": "STRING"
       }
     ],
     "resultFormat": "compactedList",
     "columns": [
       "k"
     ],
     "legacy": false,
     "context": {
       "populateCache": false,
       "queryId": "af155c04-9132-4058-b912-e73a0a6fbd9c",
       "sqlQueryId": "af155c04-9132-4058-b912-e73a0a6fbd9c",
       "useApproximateCountDistinct": false,
       "useApproximateTopN": false,
       "useCache": false,
       "useNativeQueryExplain": true
     },
     "granularity": {
       "type": "all"
     }
   }
   ```
   
   And if run the following request, I can’t even retrieve the native query:
   
   ```sql
   select caseid, __time
   from "30ef4a57-3647-4785-b7ca-9cbd568ae7c1-1"
   join (
     select isCompletedCasesLookup.k "filter"
     from lookup."30ef4a57-3647-4785-b7ca-9cbd568ae7c1-1_cases_is_completed" 
"isCompletedCasesLookup"
     where isCompletedCasesLookup.v = 'FALSE' and isCompletedCasesLookup.v = 
'TRUE'
   ) on caseid = "filter"
   group by 
     caseid, 
     __time
   order by 
     __time desc, 
     caseid
   ```
   


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