villebro commented on a change in pull request #13294:
URL: https://github.com/apache/superset/pull/13294#discussion_r583015764



##########
File path: superset/db_engine_specs/postgres.py
##########
@@ -45,6 +48,28 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
     engine = ""
     engine_name = "PostgreSQL"
 
+    column_type_mappings = (
+        (re.compile(r"^smallint", re.IGNORECASE), types.SMALLINT),
+        (re.compile(r"^integer", re.IGNORECASE), types.INTEGER),
+        (re.compile(r"^bigint", re.IGNORECASE), types.BIGINT),
+        (re.compile(r"^decimal", re.IGNORECASE), types.DECIMAL),
+        (re.compile(r"^numeric", re.IGNORECASE), types.NUMERIC),
+        (re.compile(r"^real", re.IGNORECASE), types.REAL),
+        (re.compile(r"^double precision", re.IGNORECASE), DOUBLE_PRECISION),
+        (re.compile(r"^smallserial", re.IGNORECASE), types.SMALLINT),
+        (re.compile(r"^serial", re.IGNORECASE), types.INTEGER),
+        (re.compile(r"^bigserial", re.IGNORECASE), types.BIGINT),
+        (re.compile(r"^varchar", re.IGNORECASE), types.VARCHAR),
+        (re.compile(r"^char", re.IGNORECASE), types.CHAR),
+        (re.compile(r"^text", re.IGNORECASE), types.TEXT),
+        (re.compile(r"^date", re.IGNORECASE), types.DATE),
+        (re.compile(r"^time", re.IGNORECASE), types.TIME),
+        (re.compile(r"^timestamp", re.IGNORECASE), types.TIMESTAMP),
+        (re.compile(r"^timestamptz", re.IGNORECASE), 
types.TIMESTAMP(timezone=True)),

Review comment:
       Were you able to get these from `inspector.get_columns()` or 
`cursor.description`? When I check a table with timestamps it seems to return 
the unabbreviated format `TIMESTAMP WITHOUT TIME ZONE`, not `TIMESTAMP`:
   
![image](https://user-images.githubusercontent.com/33317356/109190205-86cbb500-779d-11eb-8613-56e6f9658a08.png)
    
   I'm assuming the abbreviations are usually relevant when creating tables, 
not fetching table metadata, but I may be wrong (this may have changed over the 
versions/years):
   
   
![image](https://user-images.githubusercontent.com/33317356/109205645-8b996480-77af-11eb-993b-018d949f0cf7.png)
   




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to