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

   ### Bug description
   
   Some field alias create an issue
   
   The sample query dataset bellow work
   
   ```
   select '[email protected]' as "Adresse"
   union select '[email protected]'
   ```
   but  sample query dataset bellow not work with error "Custom SQL fields 
cannot contain sub-queries."
   
   ```
   select '[email protected]' as "Adresse E-mail"
   union select '[email protected]'
   ```
   
   alias like "Appartement / étage", "Bâtiment / Résidence", "C.Postal" work 
good
   
   but "Adresse E-mail" and "Nom de struture" not work
   
   
   
   ```
   mars 14 14:37:22 superset gunicorn[17914]: 2025-03-14 
14:37:22,913:WARNING:superset.views.error_handling:SupersetErrorException
   mars 14 14:37:22 superset gunicorn[17914]: Traceback (most recent call last):
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/flask/app.py", line 1484, 
in full_dispatch_request
   mars 14 14:37:22 superset gunicorn[17914]:     rv = self.dispatch_request()
   mars 14 14:37:22 superset gunicorn[17914]:          ^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/flask/app.py", line 1469, 
in dispatch_request
   mars 14 14:37:22 superset gunicorn[17914]:     return 
self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
   mars 14 14:37:22 superset gunicorn[17914]:            
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/flask_appbuilder/security/decorators.py",
 line 109, in wraps
   mars 14 14:37:22 superset gunicorn[17914]:     return f(self, *args, 
**kwargs)
   mars 14 14:37:22 superset gunicorn[17914]:            
^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/views/base_api.py",
 line 119, in wraps
   mars 14 14:37:22 superset gunicorn[17914]:     duration, response = 
time_function(f, self, *args, **kwargs)
   mars 14 14:37:22 superset gunicorn[17914]:                          
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/utils/core.py", 
line 1364, in time_function
   mars 14 14:37:22 superset gunicorn[17914]:     response = func(*args, 
**kwargs)
   mars 14 14:37:22 superset gunicorn[17914]:                
^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/utils/log.py", 
line 303, in wrapper
   mars 14 14:37:22 superset gunicorn[17914]:     value = f(*args, **kwargs)
   mars 14 14:37:22 superset gunicorn[17914]:             ^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/charts/data/api.py",
 line 260, in data
   mars 14 14:37:22 superset gunicorn[17914]:     return 
self._get_data_response(
   mars 14 14:37:22 superset gunicorn[17914]:            
^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/charts/data/api.py",
 line 416, in _get_data_response
   mars 14 14:37:22 superset gunicorn[17914]:     result = 
command.run(force_cached=force_cached)
   mars 14 14:37:22 superset gunicorn[17914]:              
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/commands/chart/data/get_data_command.py",
 line 45, in run
   mars 14 14:37:22 superset gunicorn[17914]:     payload = 
self._query_context.get_payload(
   mars 14 14:37:22 superset gunicorn[17914]:               
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/common/query_context.py",
 line 102, in get_payload
   mars 14 14:37:22 superset gunicorn[17914]:     return 
self._processor.get_payload(cache_query_context, force_cached)
   mars 14 14:37:22 superset gunicorn[17914]:            
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/common/query_context_processor.py",
 line 675, in get_payload
   mars 14 14:37:22 superset gunicorn[17914]:     query_results = [
   mars 14 14:37:22 superset gunicorn[17914]:                     ^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/common/query_context_processor.py",
 line 676, in <listcomp>
   mars 14 14:37:22 superset gunicorn[17914]:     get_query_results(
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/common/query_actions.py",
 line 227, in get_query_results
   mars 14 14:37:22 superset gunicorn[17914]:     return 
result_func(query_context, query_obj, force_cached)
   mars 14 14:37:22 superset gunicorn[17914]:            
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/common/query_actions.py",
 line 189, in _get_results
   mars 14 14:37:22 superset gunicorn[17914]:     payload = 
_get_full(query_context, query_obj, force_cached)
   mars 14 14:37:22 superset gunicorn[17914]:               
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/common/query_actions.py",
 line 103, in _get_full
   mars 14 14:37:22 superset gunicorn[17914]:     payload = 
query_context.get_df_payload(query_obj, force_cached=force_cached)
   mars 14 14:37:22 superset gunicorn[17914]:               
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/common/query_context.py",
 line 123, in get_df_payload
   mars 14 14:37:22 superset gunicorn[17914]:     return 
self._processor.get_df_payload(
   mars 14 14:37:22 superset gunicorn[17914]:            
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/common/query_context_processor.py",
 line 158, in get_df_payload
   mars 14 14:37:22 superset gunicorn[17914]:     query_result = 
self.get_query_result(query_obj)
   mars 14 14:37:22 superset gunicorn[17914]:                    
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/common/query_context_processor.py",
 line 237, in get_query_result
   mars 14 14:37:22 superset gunicorn[17914]:     result = 
query_context.datasource.query(query_object.to_dict())
   mars 14 14:37:22 superset gunicorn[17914]:              
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/connectors/sqla/models.py",
 line 1729, in query
   mars 14 14:37:22 superset gunicorn[17914]:     query_str_ext = 
self.get_query_str_extended(query_obj)
   mars 14 14:37:22 superset gunicorn[17914]:                     
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/models/helpers.py",
 line 880, in get_query_str_extended
   mars 14 14:37:22 superset gunicorn[17914]:     sqlaq = 
self.get_sqla_query(**query_obj)
   mars 14 14:37:22 superset gunicorn[17914]:             
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/models/helpers.py",
 line 1653, in get_sqla_query
   mars 14 14:37:22 superset gunicorn[17914]:     selected = 
validate_adhoc_subquery(
   mars 14 14:37:22 superset gunicorn[17914]:                
^^^^^^^^^^^^^^^^^^^^^^^^
   mars 14 14:37:22 superset gunicorn[17914]:   File 
"/var/lib/superset/.venv/lib/python3.11/site-packages/superset/models/helpers.py",
 line 138, in validate_adhoc_subquery
   mars 14 14:37:22 superset gunicorn[17914]:     raise 
SupersetSecurityException(
   mars 14 14:37:22 superset gunicorn[17914]: 
superset.exceptions.SupersetSecurityException: Custom SQL fields cannot contain 
sub-queries.
   
   ```
   
   ### Screenshots/recordings
   
   
![Image](https://github.com/user-attachments/assets/9cb11e84-7169-4bdf-b4a3-19140c97d430)
   
   
![Image](https://github.com/user-attachments/assets/126374c9-4c8f-4767-a135-c75724f34746)
   
   
![Image](https://github.com/user-attachments/assets/048e217b-4a60-4838-a221-c117bc3a9ae5)
   
   
![Image](https://github.com/user-attachments/assets/d01d5bd8-e257-4390-87c7-1c8cfe56e750)
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.11
   
   ### Node version
   
   18 or greater
   
   ### Browser
   
   Not applicable
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [ ] 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