You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/09/09 07:01:14 UTC

[GitHub] [incubator-superset] villebro commented on a change in pull request #10270: [WIP] refactor: migrate table chart to new API

villebro commented on a change in pull request #10270:
URL: https://github.com/apache/incubator-superset/pull/10270#discussion_r485376616



##########
File path: superset/connectors/sqla/models.py
##########
@@ -158,21 +158,21 @@ class TableColumn(Model, BaseColumn):
     def is_numeric(self) -> bool:
         db_engine_spec = self.table.database.db_engine_spec
         return db_engine_spec.is_db_column_type_match(
-            self.type, utils.DbColumnType.NUMERIC
+            self.type, utils.GenericColumnType.NUMERIC

Review comment:
       I like the new name 👍 

##########
File path: superset/db_engine_specs/base.py
##########
@@ -150,9 +150,10 @@ class BaseEngineSpec:  # pylint: disable=too-many-public-methods
     max_column_name_length = 0
     try_remove_schema_from_table_name = True  # pylint: disable=invalid-name
 
-    # default matching patterns for identifying column types
-    db_column_types: Dict[utils.DbColumnType, Tuple[Pattern[Any], ...]] = {
-        utils.DbColumnType.NUMERIC: (
+    # default matching patterns to convert database specific column types to
+    # more generic types
+    db_column_types: Dict[utils.GenericColumnType, Tuple[Pattern[Any], ...]] = {

Review comment:
       Bycatch nit: I think this should be enough.
   ```suggestion
       db_column_types: Dict[utils.GenericColumnType, Tuple[Pattern[str], ...]] = {
   ```

##########
File path: superset/utils/core.py
##########
@@ -1407,14 +1407,15 @@ class QuerySource(Enum):
     SQL_LAB = 2
 
 
-class DbColumnType(Enum):
+class GenericColumnType(IntEnum):
     """
-    Generic database column type
+    Generic database column type that fits both frontend and backend.
     """
 
     NUMERIC = 0
     STRING = 1
     TEMPORAL = 2
+    BOOLEAN = 3

Review comment:
       It's good to be mindful that `BOOLEAN` types are sometimes `NUMERIC` (0/1). For example on MySQL, `BIT` is synonymous with `TINYINT(1)` which is essentially `NUMERIC`.

##########
File path: superset/common/query_context.py
##########
@@ -160,6 +160,8 @@ def get_single_payload(self, query_obj: QueryObject) -> Dict[str, Any]:
         df = payload["df"]
         status = payload["status"]
         if status != utils.QueryStatus.FAILED:
+            payload['columns'] = list(df.columns)
+            payload['dtypes'] = utils.serialize_dtypes(df.dtypes)

Review comment:
       🎉  This is long overdue! Could we call this something less Pandas'y, like `types` or `column_types`? Please also add these to `ChartDataResponseResult` in `superset/chart/schema.py`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org