From 54651951545e7afff30d8a3f416ba09434e4f145 Mon Sep 17 00:00:00 2001 From: Allen Short Date: Mon, 9 Jul 2018 13:20:36 -0500 Subject: [PATCH] Filter tables from schema browser (re #31) --- client/app/pages/queries/QuerySource.jsx | 1 + .../queries/components/SchemaBrowser.jsx | 57 +++++++++++++++++-- redash/handlers/api.py | 3 + redash/handlers/data_sources.py | 14 +++++ redash/query_runner/__init__.py | 6 ++ redash/query_runner/athena.py | 6 ++ redash/query_runner/axibase_tsd.py | 6 ++ redash/query_runner/big_query.py | 6 ++ redash/query_runner/cass.py | 6 ++ redash/query_runner/clickhouse.py | 6 ++ redash/query_runner/dynamodb_sql.py | 6 ++ redash/query_runner/elasticsearch.py | 6 ++ redash/query_runner/google_analytics.py | 10 +++- redash/query_runner/google_spreadsheets.py | 10 +++- redash/query_runner/graphite.py | 6 ++ redash/query_runner/hive_ds.py | 7 ++- redash/query_runner/impala_ds.py | 6 ++ redash/query_runner/influx_db.py | 10 +++- redash/query_runner/memsql_ds.py | 6 ++ redash/query_runner/mongodb.py | 10 +++- redash/query_runner/mssql.py | 6 ++ redash/query_runner/mysql.py | 6 ++ redash/query_runner/oracle.py | 6 ++ redash/query_runner/pg.py | 6 ++ redash/query_runner/presto.py | 6 ++ redash/query_runner/python.py | 6 ++ redash/query_runner/salesforce.py | 6 ++ redash/query_runner/script.py | 6 ++ redash/query_runner/snowflake.py | 6 ++ redash/query_runner/sqlite.py | 10 +++- redash/query_runner/treasuredata.py | 6 ++ redash/query_runner/vertica.py | 6 ++ 32 files changed, 253 insertions(+), 11 deletions(-) diff --git a/client/app/pages/queries/QuerySource.jsx b/client/app/pages/queries/QuerySource.jsx index 5f43495f58..79b9e40287 100644 --- a/client/app/pages/queries/QuerySource.jsx +++ b/client/app/pages/queries/QuerySource.jsx @@ -223,6 +223,7 @@ function QuerySource(props) {
refreshSchema(true)} onItemSelect={handleSchemaItemSelect} /> diff --git a/client/app/pages/queries/components/SchemaBrowser.jsx b/client/app/pages/queries/components/SchemaBrowser.jsx index bd5d1a487f..5eb1319d0d 100644 --- a/client/app/pages/queries/components/SchemaBrowser.jsx +++ b/client/app/pages/queries/components/SchemaBrowser.jsx @@ -1,12 +1,16 @@ import { isNil, map, filter, some, includes } from "lodash"; +import { axios } from "@/services/axios"; import React, { useState, useCallback, useMemo, useEffect } from "react"; import PropTypes from "prop-types"; import { useDebouncedCallback } from "use-debounce"; +import Checkbox from "antd/lib/checkbox"; import Input from "antd/lib/input"; import Button from "antd/lib/button"; import Tooltip from "antd/lib/tooltip"; import AutoSizer from "react-virtualized/dist/commonjs/AutoSizer"; import List from "react-virtualized/dist/commonjs/List"; +import { clientConfig } from "@/services/auth"; +import notification from "@/services/notification"; const SchemaItemType = PropTypes.shape({ name: PropTypes.string.isRequired, @@ -77,9 +81,22 @@ SchemaItem.defaultProps = { onSelect: () => {}, }; -function applyFilter(schema, filterString) { +function applyFilter(schema, filterString, showHidden, toggleString) { const filters = filter(filterString.toLowerCase().split(/\s+/), s => s.length > 0); + // Filter out extra schema that match the provided toggle string + if (!showHidden && toggleString) { + const toggleStringRegex = new RegExp(toggleString); + try { + schema = filter( + schema, + item => !item.name.toLowerCase().match(toggleStringRegex) + ); + } catch (err) { + notification.error(`Error while matching schema items: ${err}`); + } + } + // Empty string: return original schema if (filters.length === 0) { return schema; @@ -110,17 +127,39 @@ function applyFilter(schema, filterString) { ); } -export default function SchemaBrowser({ schema, onRefresh, onItemSelect, ...props }) { + +function useToggleString(dataSourceId) { + const [toggleString, setToggleString] = useState(""); + useMemo(() => { + if (!dataSourceId) { + return null; + } + axios.get( + `${clientConfig.basePath}api/data_sources/${dataSourceId}/toggle_string` + ).then(data => { + setToggleString(data.toggle_string); + }) + }, [dataSourceId]); + return toggleString; +} + + +export default function SchemaBrowser({ schema, dataSourceId, onRefresh, onItemSelect, ...props }) { const [filterString, setFilterString] = useState(""); - const filteredSchema = useMemo(() => applyFilter(schema, filterString), [schema, filterString]); + const [showHidden, setShowHidden] = useState(false); + const toggleString = useToggleString(dataSourceId); + const filteredSchema = useMemo(() => applyFilter(schema, filterString, + showHidden, toggleString), [schema, filterString, showHidden, toggleString]); const [expandedFlags, setExpandedFlags] = useState({}); const [handleFilterChange] = useDebouncedCallback(setFilterString, 500); + const [handleToggleChange] = useDebouncedCallback(setShowHidden, 100); const [listRef, setListRef] = useState(null); useEffect(() => { setExpandedFlags({}); }, [schema]); + useEffect(() => { if (listRef) { listRef.recomputeRowHeights(); @@ -147,13 +186,21 @@ export default function SchemaBrowser({ schema, onRefresh, onItemSelect, ...prop disabled={schema.length === 0} onChange={event => handleFilterChange(event.target.value)} /> -
+
+ {toggleString && + handleToggleChange(event.target.checked)}> + Show hidden schema + } +
{({ width, height }) => ( @@ -190,12 +237,14 @@ export default function SchemaBrowser({ schema, onRefresh, onItemSelect, ...prop SchemaBrowser.propTypes = { schema: PropTypes.arrayOf(SchemaItemType), + dataSourceId: PropTypes.number, onRefresh: PropTypes.func, onItemSelect: PropTypes.func, }; SchemaBrowser.defaultProps = { schema: [], + dataSourceId: null, onRefresh: () => {}, onItemSelect: () => {}, }; diff --git a/redash/handlers/api.py b/redash/handlers/api.py index ef479ef3c3..e26ffd329f 100644 --- a/redash/handlers/api.py +++ b/redash/handlers/api.py @@ -25,6 +25,7 @@ DataSourceSchemaResource, DataSourceTestResource, DataSourceTypeListResource, + DataSourceToggleStringResource, ) from redash.handlers.destinations import ( DestinationListResource, @@ -152,6 +153,8 @@ def json_representation(data, code, headers=None): api.add_org_resource( DataSourceResource, "/api/data_sources/", endpoint="data_source" ) +api.add_resource(DataSourceToggleStringResource, "/api/data_sources//toggle_string") + api.add_org_resource(GroupListResource, "/api/groups", endpoint="groups") api.add_org_resource(GroupResource, "/api/groups/", endpoint="group") diff --git a/redash/handlers/data_sources.py b/redash/handlers/data_sources.py index b3521ca070..5746dab0ee 100644 --- a/redash/handlers/data_sources.py +++ b/redash/handlers/data_sources.py @@ -266,3 +266,17 @@ def post(self, data_source_id): } ) return response + + +class DataSourceToggleStringResource(BaseResource): + def get(self, data_source_id): + data_source = get_object_or_404( + models.DataSource.get_by_id_and_org, data_source_id, self.current_org + ) + require_access(data_source.groups, self.current_user, view_only) + try: + return { + "toggle_string": data_source.options.get("toggle_table_string", "") + } + except Exception: + abort(400) diff --git a/redash/query_runner/__init__.py b/redash/query_runner/__init__.py index d5f4f1c930..4761efe3eb 100644 --- a/redash/query_runner/__init__.py +++ b/redash/query_runner/__init__.py @@ -232,6 +232,12 @@ def configuration_schema(cls): "url": {"type": "string", "title": cls.url_title}, "username": {"type": "string", "title": cls.username_title}, "password": {"type": "string", "title": cls.password_title}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "secret": ["password"], "order": ["url", "username", "password"], diff --git a/redash/query_runner/athena.py b/redash/query_runner/athena.py index 35a2ba5dc5..3e39b18075 100644 --- a/redash/query_runner/athena.py +++ b/redash/query_runner/athena.py @@ -82,6 +82,12 @@ def configuration_schema(cls): "title": "Athena cost per Tb scanned (USD)", "default": 5, }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["region", "s3_staging_dir"], "extra_options": ["glue", "cost_per_tb"], diff --git a/redash/query_runner/axibase_tsd.py b/redash/query_runner/axibase_tsd.py index ecb1af5cba..bd9bf8df1a 100644 --- a/redash/query_runner/axibase_tsd.py +++ b/redash/query_runner/axibase_tsd.py @@ -115,6 +115,12 @@ def configuration_schema(cls): "type": "boolean", "title": "Trust SSL Certificate", }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["username", "password", "hostname", "protocol", "port"], "secret": ["password"], diff --git a/redash/query_runner/big_query.py b/redash/query_runner/big_query.py index 1b29de7ff3..5607832639 100644 --- a/redash/query_runner/big_query.py +++ b/redash/query_runner/big_query.py @@ -117,6 +117,12 @@ def configuration_schema(cls): "type": "number", "title": "Maximum Billing Tier", }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["jsonKeyFile", "projectId"], "order": [ diff --git a/redash/query_runner/cass.py b/redash/query_runner/cass.py index 4a49c0d9b1..94d95d1854 100644 --- a/redash/query_runner/cass.py +++ b/redash/query_runner/cass.py @@ -77,6 +77,12 @@ def configuration_schema(cls): "PROTOCOL_TLSv1_2", ], }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["keyspace", "host", "useSsl"], "secret": ["sslCertificateFile"], diff --git a/redash/query_runner/clickhouse.py b/redash/query_runner/clickhouse.py index c2a1c6ebb5..cc5f8e4f92 100644 --- a/redash/query_runner/clickhouse.py +++ b/redash/query_runner/clickhouse.py @@ -32,6 +32,12 @@ def configuration_schema(cls): "title": "Verify SSL certificate", "default": True, }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "order": ["url", "user", "password", "dbname"], "required": ["dbname"], diff --git a/redash/query_runner/dynamodb_sql.py b/redash/query_runner/dynamodb_sql.py index 965cc8fc2f..fa99c0ee12 100644 --- a/redash/query_runner/dynamodb_sql.py +++ b/redash/query_runner/dynamodb_sql.py @@ -44,6 +44,12 @@ def configuration_schema(cls): "region": {"type": "string", "default": "us-east-1"}, "access_key": {"type": "string"}, "secret_key": {"type": "string"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["access_key", "secret_key"], "secret": ["secret_key"], diff --git a/redash/query_runner/elasticsearch.py b/redash/query_runner/elasticsearch.py index d96dd1e433..5658b5fb50 100644 --- a/redash/query_runner/elasticsearch.py +++ b/redash/query_runner/elasticsearch.py @@ -56,6 +56,12 @@ def configuration_schema(cls): "type": "string", "title": "Basic Auth Password", }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "order": ["server", "basic_auth_user", "basic_auth_password"], "secret": ["basic_auth_password"], diff --git a/redash/query_runner/google_analytics.py b/redash/query_runner/google_analytics.py index 9956f5d5f3..fbd6763506 100644 --- a/redash/query_runner/google_analytics.py +++ b/redash/query_runner/google_analytics.py @@ -103,7 +103,15 @@ def enabled(cls): def configuration_schema(cls): return { "type": "object", - "properties": {"jsonKeyFile": {"type": "string", "title": "JSON Key File"}}, + "properties": { + "jsonKeyFile": {"type": "string", "title": "JSON Key File"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, + }, "required": ["jsonKeyFile"], "secret": ["jsonKeyFile"], } diff --git a/redash/query_runner/google_spreadsheets.py b/redash/query_runner/google_spreadsheets.py index c9f159c75b..e747e7075b 100644 --- a/redash/query_runner/google_spreadsheets.py +++ b/redash/query_runner/google_spreadsheets.py @@ -166,7 +166,15 @@ def enabled(cls): def configuration_schema(cls): return { "type": "object", - "properties": {"jsonKeyFile": {"type": "string", "title": "JSON Key File"}}, + "properties": { + "jsonKeyFile": {"type": "string", "title": "JSON Key File"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, + }, "required": ["jsonKeyFile"], "secret": ["jsonKeyFile"], } diff --git a/redash/query_runner/graphite.py b/redash/query_runner/graphite.py index 3bbf098598..d7285b8637 100644 --- a/redash/query_runner/graphite.py +++ b/redash/query_runner/graphite.py @@ -45,6 +45,12 @@ def configuration_schema(cls): "username": {"type": "string"}, "password": {"type": "string"}, "verify": {"type": "boolean", "title": "Verify SSL certificate"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["url"], "secret": ["password"], diff --git a/redash/query_runner/hive_ds.py b/redash/query_runner/hive_ds.py index 1baab89560..2fa2389759 100644 --- a/redash/query_runner/hive_ds.py +++ b/redash/query_runner/hive_ds.py @@ -50,6 +50,12 @@ def configuration_schema(cls): "port": {"type": "number"}, "database": {"type": "string"}, "username": {"type": "string"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "order": ["host", "port", "database", "username"], "required": ["host"], @@ -111,7 +117,6 @@ def _get_connection(self): database=self.configuration.get("database", "default"), username=self.configuration.get("username", None), ) - return connection def run_query(self, query, user): diff --git a/redash/query_runner/impala_ds.py b/redash/query_runner/impala_ds.py index 9981586142..68596513d6 100644 --- a/redash/query_runner/impala_ds.py +++ b/redash/query_runner/impala_ds.py @@ -56,6 +56,12 @@ def configuration_schema(cls): "ldap_user": {"type": "string"}, "ldap_password": {"type": "string"}, "timeout": {"type": "number"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["host"], "secret": ["ldap_password"], diff --git a/redash/query_runner/influx_db.py b/redash/query_runner/influx_db.py index 6ca3ecb23c..fbd90e1437 100644 --- a/redash/query_runner/influx_db.py +++ b/redash/query_runner/influx_db.py @@ -55,7 +55,15 @@ class InfluxDB(BaseQueryRunner): def configuration_schema(cls): return { "type": "object", - "properties": {"url": {"type": "string"}}, + "properties": { + "url": {"type": "string"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, + }, "required": ["url"], } diff --git a/redash/query_runner/memsql_ds.py b/redash/query_runner/memsql_ds.py index d1c235608d..dc0bf9d8c8 100644 --- a/redash/query_runner/memsql_ds.py +++ b/redash/query_runner/memsql_ds.py @@ -50,6 +50,12 @@ def configuration_schema(cls): "port": {"type": "number"}, "user": {"type": "string"}, "password": {"type": "string"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["host", "port"], "secret": ["password"], diff --git a/redash/query_runner/mongodb.py b/redash/query_runner/mongodb.py index 7a8a224e4f..88f7372148 100644 --- a/redash/query_runner/mongodb.py +++ b/redash/query_runner/mongodb.py @@ -148,13 +148,19 @@ def configuration_schema(cls): "type": "string", "extendedEnum": [ {"value": "primaryPreferred", "name": "Primary Preferred"}, - {"value": "primary", "name": "Primary"}, + {"value": "primary", "name": "Primary"}, {"value": "secondary", "name": "Secondary"}, {"value": "secondaryPreferred", "name": "Secondary Preferred"}, {"value": "nearest", "name": "Nearest"}, ], "title": "Replica Set Read Preference", - } + }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["connectionString", "dbName"], } diff --git a/redash/query_runner/mssql.py b/redash/query_runner/mssql.py index 73cd38d3a8..79db424e26 100644 --- a/redash/query_runner/mssql.py +++ b/redash/query_runner/mssql.py @@ -50,6 +50,12 @@ def configuration_schema(cls): "title": "Character Set", }, "db": {"type": "string", "title": "Database Name"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["db"], "secret": ["password"], diff --git a/redash/query_runner/mysql.py b/redash/query_runner/mysql.py index 61dfde8c1c..a5b73bef32 100644 --- a/redash/query_runner/mysql.py +++ b/redash/query_runner/mysql.py @@ -66,6 +66,12 @@ def configuration_schema(cls): "passwd": {"type": "string", "title": "Password"}, "db": {"type": "string", "title": "Database name"}, "port": {"type": "number", "default": 3306}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "order": ["host", "port", "user", "passwd", "db"], "required": ["db"], diff --git a/redash/query_runner/oracle.py b/redash/query_runner/oracle.py index 26d80592a6..4fe41db067 100644 --- a/redash/query_runner/oracle.py +++ b/redash/query_runner/oracle.py @@ -59,6 +59,12 @@ def configuration_schema(cls): "port": {"type": "number"}, "servicename": {"type": "string", "title": "DSN Service Name"}, "encoding": {"type": "string"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["servicename", "user", "password", "host", "port"], "extra_options": ["encoding"], diff --git a/redash/query_runner/pg.py b/redash/query_runner/pg.py index d7be8efc0b..efbea9a626 100644 --- a/redash/query_runner/pg.py +++ b/redash/query_runner/pg.py @@ -171,6 +171,12 @@ def configuration_schema(cls): "type": "string", "title": "SSL Client Key" }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "order": ["host", "port", "user", "password"], "required": ["dbname"], diff --git a/redash/query_runner/presto.py b/redash/query_runner/presto.py index ac76c5e710..a7ffddc3f9 100644 --- a/redash/query_runner/presto.py +++ b/redash/query_runner/presto.py @@ -46,6 +46,12 @@ def configuration_schema(cls): "catalog": {"type": "string"}, "username": {"type": "string"}, "password": {"type": "string"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "order": [ "host", diff --git a/redash/query_runner/python.py b/redash/query_runner/python.py index f7934f431d..d0a7f4eba2 100644 --- a/redash/query_runner/python.py +++ b/redash/query_runner/python.py @@ -79,6 +79,12 @@ def configuration_schema(cls): "title": "Modules to import prior to running the script", }, "additionalModulesPaths": {"type": "string"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, } diff --git a/redash/query_runner/salesforce.py b/redash/query_runner/salesforce.py index fb0eeea9bb..3f1bd261f4 100644 --- a/redash/query_runner/salesforce.py +++ b/redash/query_runner/salesforce.py @@ -77,6 +77,12 @@ def configuration_schema(cls): "title": "Salesforce API Version", "default": DEFAULT_API_VERSION, }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["username", "password", "token"], "secret": ["password", "token"], diff --git a/redash/query_runner/script.py b/redash/query_runner/script.py index 9adb1851c9..ae2a342442 100644 --- a/redash/query_runner/script.py +++ b/redash/query_runner/script.py @@ -45,6 +45,12 @@ def configuration_schema(cls): "type": "boolean", "title": "Execute command through the shell", }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["path"], } diff --git a/redash/query_runner/snowflake.py b/redash/query_runner/snowflake.py index 3e32f572d5..34556457c6 100644 --- a/redash/query_runner/snowflake.py +++ b/redash/query_runner/snowflake.py @@ -45,6 +45,12 @@ def configuration_schema(cls): "warehouse": {"type": "string"}, "database": {"type": "string"}, "region": {"type": "string", "default": "us-west"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "order": ["account", "user", "password", "warehouse", "database", "region"], "required": ["user", "password", "account", "database", "warehouse"], diff --git a/redash/query_runner/sqlite.py b/redash/query_runner/sqlite.py index ffee42bf7f..f88bd06fbb 100644 --- a/redash/query_runner/sqlite.py +++ b/redash/query_runner/sqlite.py @@ -14,7 +14,15 @@ class Sqlite(BaseSQLQueryRunner): def configuration_schema(cls): return { "type": "object", - "properties": {"dbpath": {"type": "string", "title": "Database Path"}}, + "properties": { + "dbpath": {"type": "string", "title": "Database Path"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, + }, "required": ["dbpath"], } diff --git a/redash/query_runner/treasuredata.py b/redash/query_runner/treasuredata.py index 763b3e3c4a..d0541fc673 100644 --- a/redash/query_runner/treasuredata.py +++ b/redash/query_runner/treasuredata.py @@ -52,6 +52,12 @@ def configuration_schema(cls): "title": "Auto Schema Retrieval", "default": False, }, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["apikey", "db"], } diff --git a/redash/query_runner/vertica.py b/redash/query_runner/vertica.py index a6989ee7dd..f7a61fe2b4 100644 --- a/redash/query_runner/vertica.py +++ b/redash/query_runner/vertica.py @@ -42,6 +42,12 @@ def configuration_schema(cls): "port": {"type": "number"}, "read_timeout": {"type": "number", "title": "Read Timeout"}, "connection_timeout": {"type": "number", "title": "Connection Timeout"}, + "toggle_table_string": { + "type": "string", + "title": "Toggle Table String", + "default": "_v", + "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", + }, }, "required": ["database"], "order": [