Skip to content

Commit

Permalink
fix: datatype tracking issue on virtual dataset (#20088)
Browse files Browse the repository at this point in the history
* Fix datatype tracking issue on virtual dataset

* fix pytest issue on postgresql
  • Loading branch information
codemaster08240328 authored Jun 1, 2022
1 parent 3d5ae62 commit 74c5479
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions superset/db_engine_specs/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Any, Dict, List, Optional, Pattern, Tuple, TYPE_CHECKING

from flask_babel import gettext as __
from psycopg2.extensions import binary_types, string_types
from sqlalchemy.dialects.postgresql import ARRAY, DOUBLE_PRECISION, ENUM, JSON
from sqlalchemy.dialects.postgresql.base import PGInspector
from sqlalchemy.types import String
Expand Down Expand Up @@ -287,6 +288,14 @@ def get_column_spec(
native_type, column_type_mappings=column_type_mappings
)

@classmethod
def get_datatype(cls, type_code: Any) -> Optional[str]:
types = binary_types.copy()
types.update(string_types)
if type_code in types:
return types[type_code].name
return None

@classmethod
def get_cancel_query_id(cls, cursor: Any, query: Query) -> Optional[str]:
"""
Expand Down
3 changes: 1 addition & 2 deletions tests/integration_tests/sqla_models_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@

from .base_tests import SupersetTestCase


VIRTUAL_TABLE_INT_TYPES: Dict[str, Pattern[str]] = {
"hive": re.compile(r"^INT_TYPE$"),
"mysql": re.compile("^LONGLONG$"),
"postgresql": re.compile(r"^INT$"),
"postgresql": re.compile(r"^INTEGER$"),
"presto": re.compile(r"^INTEGER$"),
"sqlite": re.compile(r"^INT$"),
}
Expand Down

0 comments on commit 74c5479

Please sign in to comment.