From notifications-return-21525-archive-asf-public=cust-asf.ponee.io@superset.apache.org Sun May 26 19:49:51 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 940C818062B for ; Sun, 26 May 2019 21:49:51 +0200 (CEST) Received: (qmail 55064 invoked by uid 500); 26 May 2019 19:49:50 -0000 Mailing-List: contact notifications-help@superset.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.apache.org Delivered-To: mailing list notifications@superset.apache.org Received: (qmail 55046 invoked by uid 99); 26 May 2019 19:49:50 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 May 2019 19:49:50 +0000 From: GitBox To: notifications@superset.apache.org Subject: [GitHub] [incubator-superset] cgivre commented on a change in pull request #6610: [WIP] Add support for Apache Drill Message-ID: <155890019073.25237.2395689234739877039.gitbox@gitbox.apache.org> Date: Sun, 26 May 2019 19:49:50 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit cgivre commented on a change in pull request #6610: [WIP] Add support for Apache Drill URL: https://github.com/apache/incubator-superset/pull/6610#discussion_r287607754 ########## File path: superset/db_engine_specs.py ########## @@ -721,6 +721,70 @@ def get_table_names(cls, inspector, schema): return sorted(inspector.get_table_names()) +class DrillEngineSpec(BaseEngineSpec): + """Engine spec for Apache Drill""" + engine = 'drill' + + time_grain_functions = { + None: '{col}', + 'PT1S': "nearestDate({col}, 'SECOND')", + 'PT1M': "nearestDate({col}, 'MINUTE')", + 'PT15M': "nearestDate({col}, 'QUARTER_HOUR')", + 'PT0.5H': "nearestDate({col}, 'HALF_HOUR')", + 'PT1H': "nearestDate({col}, 'HOUR')", + 'P1D': 'TO_DATE({col})', + 'P1W': "nearestDate({col}, 'WEEK_SUNDAY')", + 'P1M': "nearestDate({col}, 'MONTH')", + 'P0.25Y': "nearestDate({col}, 'QUARTER')", + 'P1Y': "nearestDate({col}, 'YEAR')", + } + + # Returns a function to convert a Unix timestamp in milliseconds to a date + @classmethod + def epoch_to_dttm(cls): + return 'TO_DATE({col})' + + @classmethod + def convert_dttm(cls, target_type, dttm): + tt = target_type.upper() + if tt == 'DATE': + return "CAST('{}' AS DATE)".format(dttm.isoformat()[:10]) + elif tt == 'TIMESTAMP': + return "CAST('{}' AS TIMESTAMP)".format( + dttm.strftime('%Y-%m-%d %H:%M:%S')) + return "'{}'".format(dttm.strftime('%Y-%m-%d %H:%M:%S')) + + @classmethod + def adjust_database_uri(cls, uri, selected_schema): + database = uri.database + if '/' in uri.database: + database = uri.database.split('/')[0] + if selected_schema: + uri.database = database + '/' + selected_schema + return uri + + @classmethod + def extra_table_metadata(cls, database, table_name, schema_name): + return super().extra_table_metadata(database, table_name, schema_name) + + @classmethod + def select_star(cls, my_db, table_name, engine, schema=None, limit=100, + show_cols=False, indent=True, latest_partition=True, + cols=None): + + return super().select_star(my_db, table_name, engine, + schema, limit, + show_cols, indent, latest_partition, cols) + + @classmethod + def get_table_names(cls, inspector, schema): + return sorted(inspector.get_table_names(schema)) + + @classmethod + def get_view_names(cls, inspector, schema): + return sorted(inspector.get_view_names(schema)) Review comment: Removed. ---------------------------------------------------------------- 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