-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
fix(dataset): create ES-View dataset raise exception #16623 #16624
Changes from 2 commits
7f40cb3
b594531
41b7c9e
f8f3169
8945f5e
ea948de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ | |
from marshmallow import fields, Schema | ||
from marshmallow.validate import Range | ||
from sqlalchemy import column, select, types | ||
from sqlalchemy.engine.base import Engine | ||
from sqlalchemy.engine.base import Connection, Engine | ||
from sqlalchemy.engine.interfaces import Compiled, Dialect | ||
from sqlalchemy.engine.reflection import Inspector | ||
from sqlalchemy.engine.url import make_url, URL | ||
|
@@ -1343,6 +1343,21 @@ def cancel_query(cls, cursor: Any, query: Query, cancel_query_id: str) -> bool: | |
|
||
return False | ||
|
||
@classmethod | ||
def _has_view( | ||
cls, | ||
conn: Connection, | ||
dialect: Dialect, | ||
view_name: str, | ||
schema: Optional[str] = None, | ||
): | ||
view_names = dialect.get_view_names(connection=conn, schema=schema) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed, please review |
||
return view_name in view_names | ||
|
||
@classmethod | ||
def has_view(cls, engine: Engine, view_name: str, schema: Optional[str] = None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we move |
||
return engine.run_callable(cls._has_view, engine.dialect, view_name, schema) | ||
|
||
|
||
# schema for adding a database by providing parameters instead of the | ||
# full SQLAlchemy URI | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -721,6 +721,20 @@ def has_table_by_name(self, table_name: str, schema: Optional[str] = None) -> bo | |
engine = self.get_sqla_engine() | ||
return engine.has_table(table_name, schema) | ||
|
||
def has_view_by_name(self, view_name: str, schema: Optional[str] = None) -> bool: | ||
engine = self.get_sqla_engine() | ||
return db_engine_specs.BaseEngineSpec.has_view( | ||
engine=engine, view_name=view_name, schema=schema | ||
) | ||
|
||
def has_table_or_view_by_name( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same before, decouple |
||
self, name: str, schema: Optional[str] = None | ||
) -> bool: | ||
result = self.has_table_by_name( | ||
table_name=name, schema=schema | ||
) or self.has_view_by_name(view_name=name, schema=schema) | ||
return result | ||
|
||
@memoized | ||
def get_dialect(self) -> Dialect: | ||
sqla_url = url.make_url(self.sqlalchemy_uri_decrypted) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we decouple
has_table_by_name
andhas_view_by_name
?