fix: datatype tracking issue on virtual dataset (#20088)

* Fix datatype tracking issue on virtual dataset

* fix pytest issue on postgresql
This commit is contained in:
Smart-Codi
2022-06-02 05:43:11 +10:00
committed by GitHub
parent 3d5ae6226b
commit 74c5479926
2 changed files with 10 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ from datetime import datetime
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
@@ -287,6 +288,14 @@ class PostgresEngineSpec(PostgresBaseEngineSpec, BasicParametersMixin):
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]:
"""

View File

@@ -52,11 +52,10 @@ from tests.integration_tests.test_app import app
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$"),
}