Skip to content

Commit

Permalink
fix: Trino get_columns (apache#29566)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida authored Jul 12, 2024
1 parent 0d352b4 commit fa095a9
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 226 deletions.
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:
"""
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

0 comments on commit fa095a9

Please sign in to comment.