cezudas opened a new issue, #30977:
URL: https://github.com/apache/superset/issues/30977

   ### Bug description
   
   I set up a bar chart `X axis` value to a column named 'Created on'.
   When the chart data loads I get an error: "Custom SQL fields cannot contain 
sub-queries."
   
   Sample chart SQL query: `SELECT DATE_TRUNC('day', "Created on") AS "Created 
on", sum("Estimated savings / Month") AS "SUM(Estimated savings / Month)" 
   FROM public."Opportunities_4_userfriendly" 
   WHERE ("Status" NOT IN ('Dismissed', 'Completed')) GROUP BY 
DATE_TRUNC('day', "Created on") 
    LIMIT 50000;`
    
   In my case, choosing any other column containing the token 'on'  for the `X 
axis`, such as "Update on" will lead to the same error.
   My guess is the bug originates from 
`superset/models/helpers.py#validate_adhoc_subquery`. The parser is likely 
incorrectly interpreting "Created on" as a table reference because of the word 
"on"
   
   ### Screenshots/recordings
   
   ![Screenshot 2024-11-19 at 14 31 
16](https://github.com/user-attachments/assets/31dca890-1d99-4068-a4d8-68204a2d1e07)
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [X] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [X] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [X] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


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