From 71d6ff40d060a073422846a01a3deedcf1568a18 Mon Sep 17 00:00:00 2001 From: Sumedh Sakdeo <773250+sumedhsakdeo@users.noreply.github.com> Date: Mon, 29 Oct 2018 11:23:21 -0700 Subject: [PATCH] partition and clustering bigquery keys (#6212) * partition and clustering bigquery keys * flake8 --- superset/db_engine_specs.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py index 8ab5c071d..79ef886a0 100644 --- a/superset/db_engine_specs.py +++ b/superset/db_engine_specs.py @@ -1433,6 +1433,28 @@ class BQEngineSpec(BaseEngineSpec): '128 characters'.format(mutated_label)) return mutated_label + @classmethod + def extra_table_metadata(cls, database, table_name, schema_name): + indexes = database.get_indexes(table_name, schema_name) + if not indexes: + return {} + partitions_columns = [ + index.get('column_names', []) for index in indexes + if index.get('name') == 'partition' + ] + cluster_columns = [ + index.get('column_names', []) for index in indexes + if index.get('name') == 'clustering' + ] + return { + 'partitions': { + 'cols': partitions_columns, + }, + 'clustering': { + 'cols': cluster_columns, + }, + } + @classmethod def _get_fields(cls, cols): """