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

   Shillelagh query fails with error "unable to open database file" when 
running a query against a public json API in SQL lab.
   
   #### How to reproduce the bug
   
   1. Build a docker image:
   `docker build -t superset .`
   using this Dockerfile:
   ```
   FROM apache/superset
   USER root
   # https://github.com/betodealmeida/shillelagh
   RUN pip install shillelagh shillelagh['genericjsonapi']
   USER superset
   ```
   2. Run the docker image:
   ```
   docker run -d -p 8080:8088 -e "SUPERSET_SECRET_KEY=your_secret_key_here" 
--name superset --rm superset
   docker exec -it superset superset fab create-admin --username admin 
--firstname Superset --lastname Admin --email [email protected] --password 
admin
   docker exec -it superset superset db upgrade
   docker exec -it superset superset init
   docker attach superset
   ```
   3. Go to localhost:8080, add a database connection with URL 
"shillelagh+safe://". Go to advanced, put this into engine parameters then 
confirm and save:
   ```
   {"connect_args":{"adapters":["genericjsonapi"]}}
   ```
   4. Go to SQL lab, choose database Shillelagh, schema "main", query "SELECT * 
from 'https://jsonplaceholder.typicode.com/users';"
   5. Press "RUN"
   
   ### Expected results
   
   Superset should successfully execute the query and display the list of 
results.
   
   ### Actual results
   
   The query fails with error 
   ```
   Shillelagh Error
   shillelagh error: unable to open database file
   
   This may be triggered by:
   Issue 1002 - The database returned an unexpected error. 
   ```
   
   This is logged:
   ```
   [SupersetError(message='shillelagh error: unable to open database file', 
error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 
'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, 
extra={'engine_name': 'Shillelagh', 'issue_codes': [{'code': 1002, 'message': 
'Issue 1002 - The database returned an unexpected error.'}]})]
   Traceback (most recent call last):
     File "/app/superset/views/base.py", line 242, in wraps
       return f(self, *args, **kwargs)
     File "/app/superset/utils/log.py", line 265, in wrapper
       value = f(*args, **kwargs)
     File "/app/superset/views/core.py", line 2408, in sql_json
       command_result: CommandResult = command.run()
     File "/app/superset/sqllab/command.py", line 120, in run
       raise ex
     File "/app/superset/sqllab/command.py", line 102, in run
       status = self._run_sql_json_exec_from_scratch()
     File "/app/superset/sqllab/command.py", line 157, in 
_run_sql_json_exec_from_scratch
       raise ex
     File "/app/superset/sqllab/command.py", line 152, in 
_run_sql_json_exec_from_scratch
       return self._sql_json_executor.execute(
     File "/app/superset/sqllab/sql_json_executer.py", line 111, in execute
       raise SupersetErrorsException(
   superset.exceptions.SupersetErrorsException: 
[SupersetError(message='shillelagh error: unable to open database file', 
error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 
'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, 
extra={'engine_name': 'Shillelagh', 'issue_codes': [{'code': 1002, 'message': 
'Issue 1002 - The database returned an unexpected error.'}]})]
   2023-07-31 
18:37:45,701:WARNING:superset.views.base:[SupersetError(message='shillelagh 
error: unable to open database file', 
error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 
'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, 
extra={'engine_name': 'Shillelagh', 'issue_codes': [{'code': 1002, 'message': 
'Issue 1002 - The database returned an unexpected error.'}]})]
   Traceback (most recent call last):
     File "/app/superset/views/base.py", line 242, in wraps
       return f(self, *args, **kwargs)
     File "/app/superset/utils/log.py", line 265, in wrapper
       value = f(*args, **kwargs)
     File "/app/superset/views/core.py", line 2408, in sql_json
       command_result: CommandResult = command.run()
     File "/app/superset/sqllab/command.py", line 120, in run
       raise ex
     File "/app/superset/sqllab/command.py", line 102, in run
       status = self._run_sql_json_exec_from_scratch()
     File "/app/superset/sqllab/command.py", line 157, in 
_run_sql_json_exec_from_scratch
       raise ex
     File "/app/superset/sqllab/command.py", line 152, in 
_run_sql_json_exec_from_scratch
       return self._sql_json_executor.execute(
     File "/app/superset/sqllab/sql_json_executer.py", line 111, in execute
       raise SupersetErrorsException(
   superset.exceptions.SupersetErrorsException: 
[SupersetError(message='shillelagh error: unable to open database file', 
error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 
'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, 
extra={'engine_name': 'Shillelagh', 'issue_codes': [{'code': 1002, 'message': 
'Issue 1002 - The database returned an unexpected error.'}]})]
   172.17.0.1 - - [31/Jul/2023:18:37:45 +0000] "POST /superset/sql_json/ 
HTTP/1.1" 500 277 "http://localhost:8080/superset/sqllab/"; "Mozilla/5.0 
(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) 
Chrome/115.0.0.0 Safari/537.36"
   ```
   
   ### Environment
   
   ```
   $ superset --version
   Python 3.8.13 
   Flask 2.0.3   
   Werkzeug 2.0.3
   ``` 
   


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