Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Superset update 4.0.2 to 4.1.1 Connect a database error. #31737

Closed
3 tasks done
HWTsang opened this issue Jan 7, 2025 · 3 comments
Closed
3 tasks done

Superset update 4.0.2 to 4.1.1 Connect a database error. #31737

HWTsang opened this issue Jan 7, 2025 · 3 comments
Labels
install:docker Installation - docker container

Comments

@HWTsang
Copy link

HWTsang commented Jan 7, 2025

Bug description

  1. Add requirements-local.txt (clickzetta-connector-python) to docker dir. start docker-compose,
  2. Connect a database, choose ClickZetta, TEST CONNECTION
  3. Error
2025-01-07 11:05:01,285:DEBUG:superset.stats_logger:[stats_logger] (incr) test_connection_error.TypeError
2025-01-07 11:05:01,286:DEBUG:superset.stats_logger:[stats_logger] (incr) DatabaseRestApi.test_connection.warning
2025-01-07 11:05:01,286:WARNING:superset.views.error_handling:SupersetErrorsException
Traceback (most recent call last):
  File "/app/superset/commands/database/test_connection.py", line 142, in run
    with database.get_sqla_engine(override_ssh_tunnel=ssh_tunnel) as engine:
  File "/usr/local/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/app/superset/models/core.py", line 445, in get_sqla_engine
    yield self._get_sqla_engine(
  File "/app/superset/models/core.py", line 502, in _get_sqla_engine
    sqlalchemy_url = self.db_engine_spec.get_url_for_impersonation(
TypeError: ClickZettaEngineSpec.get_url_for_impersonation() takes 4 positional arguments but 5 were given

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/views/base_api.py", line 119, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/app/superset/utils/core.py", line 1364, in time_function
    response = func(*args, **kwargs)
  File "/app/superset/utils/log.py", line 303, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/views/base_api.py", line 91, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/databases/api.py", line 1215, in test_connection
    TestConnectionDatabaseCommand(item).run()
  File "/app/superset/commands/database/test_connection.py", line 234, in run
    raise DatabaseTestConnectionUnexpectedError(errors) from ex
superset.commands.database.exceptions.DatabaseTestConnectionUnexpectedError: [SupersetError(message='ClickZettaEngineSpec.get_url_for_impersonation() takes 4 positional arguments but 5 were given', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'ClickZetta', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]
  1. Change superset/models/core.py, Comment out access_token.
    image
    Change superset/db_engine_specs/base.py, Comment out access_token.
    image
  2. Restart docker
  3. Connect a database, choose ClickZetta, TEST CONNECTION
  4. Problem solving

Screenshots/recordings

image

Superset version

4.1.1

Python version

3.10

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • 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.
Copy link

dosubot bot commented Jan 7, 2025

The error you're encountering is due to a mismatch in the number of arguments expected by the get_url_for_impersonation method in the ClickZettaEngineSpec class. The method is defined to accept four parameters: url, impersonate_user, username, and access_token (though access_token might be commented out) [1].

In your case, it seems that the method is being called with five arguments, which is causing the TypeError. The solution you applied—commenting out the access_token parameter in both superset/models/core.py and superset/db_engine_specs/base.py—effectively reduces the number of arguments passed to match the method's definition, resolving the error.

To prevent this issue in the future, ensure that the method signature in ClickZettaEngineSpec matches the number of arguments being passed in the code. If access_token is not needed, it should be consistently commented out or removed from both the method definition and the call sites.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the install:docker Installation - docker container label Jan 7, 2025
@HWTsang
Copy link
Author

HWTsang commented Jan 8, 2025

After commenting out access_token, Add database no longer reports an error, but other errors appear when executing sqllab.

"GET /api/v1/database/1/tables/?q=(force:!f,schema_name:public) HTTP/1.1" 422 -

File "D:\code\python\superset-4.1.1\superset\models\core.py", line 568, in get_raw_connection
yield conn
File "D:\code\python\superset-4.1.1\superset\models\core.py", line 677, in get_df
self.db_engine_spec.execute(cursor, sql_, self)
TypeError: ClickZettaEngineSpec.execute() takes 3 positional arguments but 4 were given

image
Now I have to fall back to superset4.0.2.

@HWTsang
Copy link
Author

HWTsang commented Jan 9, 2025

This is not a superset bug. It is a clickzetta bug.

@HWTsang HWTsang closed this as completed Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
install:docker Installation - docker container
Projects
None yet
Development

No branches or pull requests

1 participant