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

   ### Bug description
   
   I have change pydruid/db/api.py and pydruid/db/sqlalchemy.py for Kerberos 
Integration. It works fine on command line with only SQLAlchemy. Here's working 
code: 
   
   ```from sqlalchemy import *
   from sqlalchemy.engine import create_engine
   from sqlalchemy.schema import *
   conn_str=f"druid+https://@druid-router:9088/druid/v2/sql";
   engine = create_engine(
        conn_str,
        connect_args={
           "kerberos": True,
           "kerberos_principal": "toto%40DONUT.COM",
           "kerberos_password": "mypassword!",
           "kerberos_service": "HTTP"
           "ssl_verify_cert": False
       }
   )
   with engine.connect() as conn:
       result = conn.execute("SELECT DISTINCT TABLE_SCHEMA FROM 
INFORMATION_SCHEMA.TABLES")
       for row in result:
           print(row)
   ```
   **I've encoded the Kerberos Principal by replacing '@' with '%40'**
   
   However, on Superset, it fails with the following configuration:
   ```
   SQLAlchemy URL = druid+https://@druid-router:9088/druid/v2/sql
   
   In Advanced/Engine Parameters
   
{"connect_args":{"kerberos":true,"kerberos_principal":"toto%40DONUT.COM","kerberos_password":"mypassword!","kerberos_service":"HTTP","ssl_verify_cert":false}}
   ```
   
   I got the following erro:
   ```WARNING:superset.views.error_handling:SupersetErrorsException
   Traceback (most recent call last):
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/superset/commands/database/test_connection.py",
 line 176, in run
       raise DBAPIError(ex_str or None, None, None)
   sqlalchemy.exc.DBAPIError: (builtins.NoneType) None
   (Background on this error at: https://sqlalche.me/e/14/dbapi)
   
   The above exception was the direct cause of the following exception:
   
   Traceback (most recent call last):
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/flask/app.py",
 line 1484, in full_dispatch_request
       rv = self.dispatch_request()
            ^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/flask/app.py",
 line 1469, in dispatch_request
       return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/flask_appbuilder/security/decorators.py",
 line 109, in wraps
       return f(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/superset/views/base_api.py",
 line 120, in wraps
       duration, response = time_function(f, self, *args, **kwargs)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/superset/utils/core.py",
 line 1369, in time_function
       response = func(*args, **kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/superset/utils/log.py",
 line 304, in wrapper
       value = f(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/superset/views/base_api.py",
 line 92, in wraps
       return f(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/superset/databases/api.py",
 line 1204, in test_connection
       TestConnectionDatabaseCommand(item).run()
     File 
"/opt/superset/.conda/envs/venv_superset/lib/python3.11/site-packages/superset/commands/database/test_connection.py",
 line 205, in run
       raise SupersetErrorsException(errors) from ex
   superset.exceptions.SupersetErrorsException: 
[SupersetError(message='(builtins.NoneType) None\n(Background on this error at: 
https://sqlalche.me/e/14/dbapi)', 
error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 
'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, 
extra={'engine_name': 'Apache Druid', 'issue_codes': [{'code': 1002, 'message': 
'Issue 1002 - The database returned an unexpected error.'}]})]```
   
   Can someone help me please?
   Thanks you so much!!!
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   5.0.0
   
   ### Python version
   
   3.11
   
   ### Node version
   
   I don't know
   
   ### 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