lilotter45 commented on issue #29378:
URL: https://github.com/apache/superset/issues/29378#issuecomment-2843039709

   Yes, I am still facing this issue. I actually just came across it via a web 
search while facing the same issue in another dataset.
   
   I'm not clear why this would be a better fit for a discussion. Should the 
jinja template not be rendered consistently between the `SELECT`, `WHERE`, 
`GROUP BY`, and `ORDER BY` clauses?
   
   Another example:
   
   ```
   CASE
     WHEN '{% if filter_values('arrival_date_field')|length %}{{ 
filter_values('arrival_date_field')[0] }}{% else %}Birth Date{% endif %}' = 
'Arrival Date' THEN 
       arrival_date 
     ELSE 
       birth_date 
     END
   ```
   
   evaluates to `'Birth Date'` in the `SELECT` and `WHERE` clauses, but is 
interpreted as the raw string in the `ORDER BY` clause:
   
   ```
   ORDER BY MAX(CASE
     WHEN '{% if filter_values('arrival_date_field')|length %}{{ 
filter_values('arrival_date_field')[0] }}{% else %}Birth Date{% endif %}' = 
'Arrival Date' THEN 
       arrival_date 
     ELSE 
       birth_date 
     END) DESC
   ```
   
   When manually replacing the jinja template in SQL Lab with the string it 
would evaluate to, the query executes successfully.


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