Skip to content

Commit

Permalink
Enable documentation links and versions of data sources (re #6).
Browse files Browse the repository at this point in the history
Refs #537, #553.

Co-authored-by: Marina Samuel <[email protected]>
Co-authored-by: Allen Short <[email protected]>
  • Loading branch information
2 people authored and jezdez committed Aug 14, 2019
1 parent 0c9d431 commit c5ece9d
Show file tree
Hide file tree
Showing 25 changed files with 568 additions and 510 deletions.
6 changes: 6 additions & 0 deletions client/app/assets/less/redash/query.less
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ a.label-tag {

.datasource-small {
visibility: hidden;
display: none !important;
}

.query-fullscreen .query-metadata__mobile {
Expand Down Expand Up @@ -593,6 +594,11 @@ nav .rg-bottom {
display: none;
}

.datasource-small {
visibility: visible;
display: inline-block !important;
}

.query-fullscreen {
flex-direction: column;
overflow: hidden;
Expand Down
2 changes: 2 additions & 0 deletions client/app/pages/queries/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ <h3>
{{ds.name}}
</ui-select-choices>
</ui-select>
<datasource-link datasource-id="query.data_source_id"></datasource-link>
<datasource-version datasource-id="query.data_source_id"></datasource-version>
</div>

<div class="editor__left__schema" ng-if="sourceMode">
Expand Down
2 changes: 2 additions & 0 deletions redash/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ def add_group(self, group, view_only=False):
db.session.add(dsg)
return dsg

setattr(self, 'data_source_groups', dsg)

def remove_group(self, group):
DataSourceGroup.query.filter(
DataSourceGroup.group == group,
Expand Down
52 changes: 32 additions & 20 deletions redash/query_runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class NotSupported(Exception):
class BaseQueryRunner(object):
deprecated = False
noop_query = None
configuration_properties = None

def __init__(self, configuration):
self.syntax = 'sql'
Expand All @@ -80,6 +81,12 @@ def annotate_query(cls):
def configuration_schema(cls):
return {}

@classmethod
def add_configuration_property(cls, property, value):
if cls.configuration_properties is None:
raise NotImplementedError()
cls.configuration_properties[property] = value

def test_connection(self):
if self.noop_query is None:
raise NotImplementedError()
Expand Down Expand Up @@ -154,31 +161,36 @@ class BaseHTTPQueryRunner(BaseQueryRunner):
url_title = 'URL base path'
username_title = 'HTTP Basic Auth Username'
password_title = 'HTTP Basic Auth Password'
configuration_properties = {
'url': {
'type': 'string',
'title': url_title,
},
'username': {
'type': 'string',
'title': username_title,
},
'password': {
'type': 'string',
'title': 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."
),
},
}

@classmethod
def configuration_schema(cls):
schema = {
'type': 'object',
'properties': {
'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."
},
},
'properties': cls.configuration_properties,
'secret': ['password'],
'order': ['url', 'username', 'password']
}
Expand Down
83 changes: 42 additions & 41 deletions redash/query_runner/big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,47 @@ def _get_query_results(jobs, project_id, location, job_id, start_index):

class BigQuery(BaseQueryRunner):
noop_query = "SELECT 1"
configuration_properties = {
'projectId': {
'type': 'string',
'title': 'Project ID'
},
'jsonKeyFile': {
"type": "string",
'title': 'JSON Key File'
},
'totalMBytesProcessedLimit': {
"type": "number",
'title': 'Scanned Data Limit (MB)'
},
'userDefinedFunctionResourceUri': {
"type": "string",
'title': 'UDF Source URIs (i.e. gs://bucket/date_utils.js, gs://bucket/string_utils.js )'
},
'useStandardSql': {
"type": "boolean",
'title': "Use Standard SQL (Beta)",
},
'location': {
"type": "string",
"title": "Processing Location",
"default": "US",
},
'loadSchema': {
"type": "boolean",
"title": "Load Schema"
},
'maximumBillingTier': {
"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."
},
}

@classmethod
def enabled(cls):
Expand All @@ -93,47 +134,7 @@ def enabled(cls):
def configuration_schema(cls):
return {
'type': 'object',
'properties': {
'projectId': {
'type': 'string',
'title': 'Project ID'
},
'jsonKeyFile': {
"type": "string",
'title': 'JSON Key File'
},
'totalMBytesProcessedLimit': {
"type": "number",
'title': 'Scanned Data Limit (MB)'
},
'userDefinedFunctionResourceUri': {
"type": "string",
'title': 'UDF Source URIs (i.e. gs://bucket/date_utils.js, gs://bucket/string_utils.js )'
},
'useStandardSql': {
"type": "boolean",
'title': "Use Standard SQL",
"default": True,
},
'location': {
"type": "string",
"title": "Processing Location",
},
'loadSchema': {
"type": "boolean",
"title": "Load Schema"
},
'maximumBillingTier': {
"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."
}
},
'properties': cls.configuration_properties,
'required': ['jsonKeyFile', 'projectId'],
"order": ['projectId', 'jsonKeyFile', 'loadSchema', 'useStandardSql', 'location', 'totalMBytesProcessedLimit', 'maximumBillingTier', 'userDefinedFunctionResourceUri'],
'secret': ['jsonKeyFile']
Expand Down
75 changes: 38 additions & 37 deletions redash/query_runner/cass.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,43 @@ def default(self, o):

class Cassandra(BaseQueryRunner):
noop_query = "SELECT dateof(now()) FROM system.local"
configuration_properties = {
'host': {
'type': 'string',
},
'port': {
'type': 'number',
'default': 9042,
},
'keyspace': {
'type': 'string',
'title': 'Keyspace name'
},
'username': {
'type': 'string',
'title': 'Username'
},
'password': {
'type': 'string',
'title': 'Password'
},
'protocol': {
'type': 'number',
'title': 'Protocol Version',
'default': 3
},
'timeout': {
'type': 'number',
'title': 'Timeout',
'default': 10
},
"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."
},
}

@classmethod
def enabled(cls):
Expand All @@ -32,43 +69,7 @@ def enabled(cls):
def configuration_schema(cls):
return {
'type': 'object',
'properties': {
'host': {
'type': 'string',
},
'port': {
'type': 'number',
'default': 9042,
},
'keyspace': {
'type': 'string',
'title': 'Keyspace name'
},
'username': {
'type': 'string',
'title': 'Username'
},
'password': {
'type': 'string',
'title': 'Password'
},
'protocol': {
'type': 'number',
'title': 'Protocol Version',
'default': 3
},
'timeout': {
'type': 'number',
'title': 'Timeout',
'default': 10
},
"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."
}
},
'properties': cls.configuration_properties,
'required': ['keyspace', 'host']
}

Expand Down
39 changes: 21 additions & 18 deletions redash/query_runner/dynamodb_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,31 @@


class DynamoDBSQL(BaseSQLQueryRunner):
noop_query = "SELECT 1"
configuration_properties = {
"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."
},
}

@classmethod
def configuration_schema(cls):
return {
"type": "object",
"properties": {
"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."
}
},
"properties": cls.configuration_properties,
"required": ["access_key", "secret_key"],
"secret": ["secret_key"]
}
Expand Down
Loading

0 comments on commit c5ece9d

Please sign in to comment.