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

Error creating Elasticsearch Dataset, raise NoSuchTable Exception #16623

Closed
3 tasks done
aniaan opened this issue Sep 7, 2021 · 0 comments
Closed
3 tasks done

Error creating Elasticsearch Dataset, raise NoSuchTable Exception #16623

aniaan opened this issue Sep 7, 2021 · 0 comments
Assignees
Labels
#bug Bug report

Comments

@aniaan
Copy link
Contributor

aniaan commented Sep 7, 2021

Error creating Elasticsearch Dataset, raise NoSuchTable Exception

Expected results

create success

Actual results

create error

Screenshots

select-es-alias

create-error

Environment

(please complete the following information):

docker: apache/superset:latest

  • superset version: superset version
  • python version: python --version
  • node.js version: node -v
  • any feature flags active:

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

By troubleshooting, I found that the error occurs when I select ES-view (actually alias), and is created correctly if the real Index is selected.

def get_physical_table_metadata(
database: Database, table_name: str, schema_name: Optional[str] = None,
) -> List[Dict[str, str]]:
"""Use SQLAlchemy inspector to get table metadata"""
db_engine_spec = database.db_engine_spec
db_dialect = database.get_dialect()
# ensure empty schema
_schema_name = schema_name if schema_name else None
# Table does not exist or is not visible to a connection.
if not database.has_table_by_name(table_name, schema=_schema_name):
raise NoSuchTableError

Here the check of whether the table_name exists in the schema is performed, without considering the case when table_name=view, the check here should be table_name in tables or table_name in views

cc: @junlincc @zhaoyongjie

traceback

Traceback (most recent call last):
File "/app/superset/datasets/commands/create.py", line 51, in run
dataset.fetch_metadata(commit=False)
File "/app/superset/connectors/sqla/models.py", line 1499, in fetch_metadata
new_columns = self.external_metadata()
File "/app/superset/connectors/sqla/models.py", line 663, in external_metadata
database=self.database, table_name=self.table_name, schema_name=self.schema,
File "/app/superset/connectors/sqla/utils.py", line 47, in get_physical_table_metadata
raise NoSuchTableError
sqlalchemy.exc.NoSuchTableError: ()
2021-09-07 23:39:39,426:WARNING:superset.datasets.commands.create:()
Traceback (most recent call last):
File "/app/superset/datasets/commands/create.py", line 51, in run
dataset.fetch_metadata(commit=False)
File "/app/superset/connectors/sqla/models.py", line 1499, in fetch_metadata
new_columns = self.external_metadata()
File "/app/superset/connectors/sqla/models.py", line 663, in external_metadata
database=self.database, table_name=self.table_name, schema_name=self.schema,
File "/app/superset/connectors/sqla/utils.py", line 47, in get_physical_table_metadata
raise NoSuchTableError
sqlalchemy.exc.NoSuchTableError: ()
Error creating model DatasetRestApi: Dataset could not be created.
Traceback (most recent call last):
File "/app/superset/datasets/commands/create.py", line 51, in run
dataset.fetch_metadata(commit=False)
File "/app/superset/connectors/sqla/models.py", line 1499, in fetch_metadata
new_columns = self.external_metadata()
File "/app/superset/connectors/sqla/models.py", line 663, in external_metadata
database=self.database, table_name=self.table_name, schema_name=self.schema,
File "/app/superset/connectors/sqla/utils.py", line 47, in get_physical_table_metadata
raise NoSuchTableError
sqlalchemy.exc.NoSuchTableError: ()
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/superset/datasets/api.py", line 251, in post
new_model = CreateDatasetCommand(g.user, item).run()
File "/app/superset/datasets/commands/create.py", line 65, in run
raise DatasetCreateFailedError() from ex
superset.datasets.commands.exceptions.DatasetCreateFailedError: Dataset could not be created.
2021-09-07 23:39:39,428:ERROR:superset.datasets.api:Error creating model DatasetRestApi: Dataset could not be created.
Traceback (most recent call last):
File "/app/superset/datasets/commands/create.py", line 51, in run
dataset.fetch_metadata(commit=False)
File "/app/superset/connectors/sqla/models.py", line 1499, in fetch_metadata
new_columns = self.external_metadata()
File "/app/superset/connectors/sqla/models.py", line 663, in external_metadata
database=self.database, table_name=self.table_name, schema_name=self.schema,
File "/app/superset/connectors/sqla/utils.py", line 47, in get_physical_table_metadata
raise NoSuchTableError
sqlalchemy.exc.NoSuchTableError: ()
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/superset/datasets/api.py", line 251, in post
new_model = CreateDatasetCommand(g.user, item).run()
File "/app/superset/datasets/commands/create.py", line 65, in run
raise DatasetCreateFailedError() from ex

@aniaan aniaan added the #bug Bug report label Sep 7, 2021
aniaan added a commit to aniaan/superset that referenced this issue Sep 7, 2021
aniaan added a commit to aniaan/superset that referenced this issue Sep 8, 2021
@dpgaspar dpgaspar self-assigned this Sep 10, 2021
zhaoyongjie pushed a commit that referenced this issue Sep 14, 2021
* fix(dataset): create es-view dataset raise exception #16623

* fix(database): fix has_view logic

* refactor(database): fix logic

* style(lint): remove unused typing

* fix(test): add test case

* fix(test): fix test case
opus-42 pushed a commit to opus-42/incubator-superset that referenced this issue Nov 14, 2021
…ache#16624)

* fix(dataset): create es-view dataset raise exception apache#16623

* fix(database): fix has_view logic

* refactor(database): fix logic

* style(lint): remove unused typing

* fix(test): add test case

* fix(test): fix test case
QAlexBall pushed a commit to QAlexBall/superset that referenced this issue Dec 28, 2021
…ache#16624)

* fix(dataset): create es-view dataset raise exception apache#16623

* fix(database): fix has_view logic

* refactor(database): fix logic

* style(lint): remove unused typing

* fix(test): add test case

* fix(test): fix test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report
Projects
None yet
Development

No branches or pull requests

3 participants