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

fix: Trino get_columns #29566

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ def _get_fields(cls, cols: list[ResultSetColumnType]) -> list[Any]:
]

@classmethod
def select_star( # pylint: disable=too-many-arguments,too-many-locals
def select_star( # pylint: disable=too-many-arguments
cls,
database: Database,
table: Table,
Expand Down Expand Up @@ -1653,14 +1653,7 @@ def select_star( # pylint: disable=too-many-arguments,too-many-locals
if show_cols:
fields = cls._get_fields(cols)

quote = engine.dialect.identifier_preparer.quote
quote_schema = engine.dialect.identifier_preparer.quote_schema
full_table_name = (
quote_schema(table.schema) + "." + quote(table.table)
if table.schema
else quote(table.table)
)

full_table_name = cls.quote_table(table, engine.dialect)
qry = select(fields).select_from(text(full_table_name))

if limit and cls.allow_limit_clause:
Expand Down Expand Up @@ -2224,6 +2217,23 @@ def denormalize_name(cls, dialect: Dialect, name: str) -> str:

return name

@classmethod
def quote_table(cls, table: Table, dialect: Dialect) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

"""
Fully quote a table name, including the schema and catalog.
"""
quoters = {
"catalog": dialect.identifier_preparer.quote_schema,
"schema": dialect.identifier_preparer.quote_schema,
"table": dialect.identifier_preparer.quote,
}

return ".".join(
function(getattr(table, key))
for key, function in quoters.items()
if getattr(table, key)
)


# schema for adding a database by providing parameters instead of the
# full SQLAlchemy URI
Expand Down
1 change: 0 additions & 1 deletion superset/db_engine_specs/couchbasedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-many-lines

from __future__ import annotations

Expand Down
Loading
Loading