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 2019/04/16 09:50:38 UTC

[GitHub] [incubator-superset] villebro commented on a change in pull request #7048: feat: add Dremio connector support

villebro commented on a change in pull request #7048: feat: add Dremio connector support
URL: https://github.com/apache/incubator-superset/pull/7048#discussion_r275714988
 
 

 ##########
 File path: superset/db_engine_specs.py
 ##########
 @@ -707,8 +707,50 @@ def convert_dttm(cls, target_type, dttm):
     def get_table_names(cls, inspector, schema):
         """Need to disregard the schema for Sqlite"""
         return sorted(inspector.get_table_names())
+        
+# Start Dremio Support
+class DremioEngineSpec(BaseEngineSpec):
+    engine = 'dremio'
+    import sqlalchemy_dremio
 
+    @classmethod
+    def get_schema_names(cls, inspector):
+        schemas = [row[0] for row in inspector.engine.execute('SHOW SCHEMAS')
+                   if not row[0].startswith('_')]
+        return schemas
+
+    @classmethod
+    def get_table_names(cls, schema, inspector):
+        sql = f'SELECT TABLE_NAME FROM INFORMATION_SCHEMA."TABLES" WHERE TABLE_SCHEMA = \'{schema}\''
+        schemas = [row[0] for row in inspector.engine.execute(sql)
+                   if not row[0].startswith('_')]
+        return sorted(schemas)
+
+    @classmethod
+    def get_normalized_column_names(cls, cursor_description):
+        columns = cursor_description if cursor_description else []
+        return [cls.normalize_column_name(col[0]) for col in columns]
+    
+    @staticmethod
+    def normalize_column_name(column_name):
 
 Review comment:
   I suggest looking at a similar EngineSpec from master branch and making as few changes as possible. In this case both methods I mentioned above have been made redundant. Regarding your comment in Slack, it seems that Dremio requires column names to be lowercase only? If so take a look at how the Redshift spec lowercases column names by overriding the `mutate_label()` method.

----------------------------------------------------------------
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


With regards,
Apache Git Services

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