sascha-coenen commented on issue #9412: Regression: SQL query with multiple 
similar CASE clauses cannot be translated to correct native json format
URL: https://github.com/apache/druid/issues/9412#issuecomment-591923866
 
 
   AH, right! 
   Thanks now I get it. I remember that NULL IS NULL evaluates to true while 
NULL = NULL does not and it seems that CASE X WHEN NULL THEN would apply an 
equals comparison and therefore not evaluate to true ever.
   
   I'm sorry but to round this off one further set of example queries that are 
using the correct syntax are needed:
   
   the following query works:
   ```
   SELECT 
        CASE WHEN cityName IS NULL THEN FALSE ELSE TRUE END AS col_a,
        CASE WHEN countryName IS NULL THEN FALSE ELSE TRUE END AS col_b
   FROM wikipedia
   GROUP BY 1, 2
   ```
   
   the following query fails. (Duplicate field name: v0)
   The only difference is the wrapping of the fields inside the REGEXP_EXTRACT 
function. 
   
   ```
   SELECT 
        CASE WHEN REGEXP_EXTRACT(cityName, '.a.*') IS NULL THEN FALSE ELSE TRUE 
END AS col_a,
        CASE WHEN REGEXP_EXTRACT(countryName, '.b.*') IS NULL THEN FALSE ELSE 
TRUE END AS col_b
   FROM wikipedia
   GROUP BY 1, 2
   
   ```
   
   This is just to have a perhaps best final test fixture that is working on 
the wikipedia dataset and is using the right CASE statement. 
   
   

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to