This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 4137fe03a0 fix(schedule-query): getUISchema function called in
SchemaForm component (#20256)
4137fe03a0 is described below
commit 4137fe03a00e0a5732141895002cd55607b28d64
Author: Rahul Raj <[email protected]>
AuthorDate: Tue Jul 5 17:16:37 2022 +0500
fix(schedule-query): getUISchema function called in SchemaForm component
(#20256)
* Revert "Superset - Release and Improvements (12-05-2022)"
* merging conflic changes
* Revert "Revert "Superset - Release and Improvements (12-05-2022)""
This reverts commit 6d18661e033faf130928cbfe0dd0daa0329221f2.
* fixed breaking changes
* sync with master
* fixed breaking flows
* fixed getUISchema function call
* added default placeholder and updated docs
* fixed format and comments
* changed flag to configuration
* fix: indentation of SCHEDULED_QUERIES dict
* fix: changed intendation for SCHEDULED_QUERIES
* fix: updated docs for SCHEDULED_QUERIES
* fix: replaced button to menu item for SCHEDULED_QUERIES
* fix: updated docs for SCHEDULED_QUERIES
* fix: trailing whitespace
---
docs/docs/installation/alerts-reports.mdx | 145 ++++++++++-----------
.../components/ScheduleQueryButton/index.tsx | 2 +-
superset/config.py | 3 +
3 files changed, 75 insertions(+), 75 deletions(-)
diff --git a/docs/docs/installation/alerts-reports.mdx
b/docs/docs/installation/alerts-reports.mdx
index a7491ad03e..6e71682dc7 100644
--- a/docs/docs/installation/alerts-reports.mdx
+++ b/docs/docs/installation/alerts-reports.mdx
@@ -391,94 +391,91 @@ You can optionally allow your users to schedule queries
directly in SQL Lab. Thi
extra metadata to saved queries, which are then picked up by an external
scheduled (like
[Apache Airflow](https://airflow.apache.org/)).
-To allow scheduled queries, add the following to your configuration file:
+To allow scheduled queries, add the following to `SCHEDULED_QUERIES` in your
configuration file:
```python
-FEATURE_FLAGS = {
- # Configuration for scheduling queries from SQL Lab. This information is
- # collected when the user clicks "Schedule query", and saved into the
`extra`
- # field of saved queries.
+SCHEDULED_QUERIES = {
+ # This information is collected when the user clicks "Schedule query",
+ # and saved into the `extra` field of saved queries.
# See: https://github.com/mozilla-services/react-jsonschema-form
- 'SCHEDULED_QUERIES': {
- 'JSONSCHEMA': {
- 'title': 'Schedule',
- 'description': (
- 'In order to schedule a query, you need to specify when it '
- 'should start running, when it should stop running, and how '
- 'often it should run. You can also optionally specify '
- 'dependencies that should be met before the query is '
- 'executed. Please read the documentation for best practices '
- 'and more information on how to specify dependencies.'
- ),
- 'type': 'object',
- 'properties': {
- 'output_table': {
- 'type': 'string',
- 'title': 'Output table name',
- },
- 'start_date': {
- 'type': 'string',
- 'title': 'Start date',
- # date-time is parsed using the chrono library, see
- # https://www.npmjs.com/package/chrono-node#usage
- 'format': 'date-time',
- 'default': 'tomorrow at 9am',
- },
- 'end_date': {
- 'type': 'string',
- 'title': 'End date',
- # date-time is parsed using the chrono library, see
- # https://www.npmjs.com/package/chrono-node#usage
- 'format': 'date-time',
- 'default': '9am in 30 days',
- },
- 'schedule_interval': {
- 'type': 'string',
- 'title': 'Schedule interval',
- },
- 'dependencies': {
- 'type': 'array',
- 'title': 'Dependencies',
- 'items': {
- 'type': 'string',
- },
- },
+ 'JSONSCHEMA': {
+ 'title': 'Schedule',
+ 'description': (
+ 'In order to schedule a query, you need to specify when it '
+ 'should start running, when it should stop running, and how '
+ 'often it should run. You can also optionally specify '
+ 'dependencies that should be met before the query is '
+ 'executed. Please read the documentation for best practices '
+ 'and more information on how to specify dependencies.'
+ ),
+ 'type': 'object',
+ 'properties': {
+ 'output_table': {
+ 'type': 'string',
+ 'title': 'Output table name',
+ },
+ 'start_date': {
+ 'type': 'string',
+ 'title': 'Start date',
+ # date-time is parsed using the chrono library, see
+ # https://www.npmjs.com/package/chrono-node#usage
+ 'format': 'date-time',
+ 'default': 'tomorrow at 9am',
+ },
+ 'end_date': {
+ 'type': 'string',
+ 'title': 'End date',
+ # date-time is parsed using the chrono library, see
+ # https://www.npmjs.com/package/chrono-node#usage
+ 'format': 'date-time',
+ 'default': '9am in 30 days',
},
- },
- 'UISCHEMA': {
'schedule_interval': {
- 'ui:placeholder': '@daily, @weekly, etc.',
+ 'type': 'string',
+ 'title': 'Schedule interval',
},
'dependencies': {
- 'ui:help': (
- 'Check the documentation for the correct format when '
- 'defining dependencies.'
- ),
+ 'type': 'array',
+ 'title': 'Dependencies',
+ 'items': {
+ 'type': 'string',
+ },
},
},
- 'VALIDATION': [
- # ensure that start_date <= end_date
- {
- 'name': 'less_equal',
- 'arguments': ['start_date', 'end_date'],
- 'message': 'End date cannot be before start date',
- # this is where the error message is shown
- 'container': 'end_date',
- },
- ],
- # link to the scheduler; this example links to an Airflow pipeline
- # that uses the query id and the output table as its name
- 'linkback': (
- 'https://airflow.example.com/admin/airflow/tree?'
- 'dag_id=query_${id}_${extra_json.schedule_info.output_table}'
- ),
},
+ 'UISCHEMA': {
+ 'schedule_interval': {
+ 'ui:placeholder': '@daily, @weekly, etc.',
+ },
+ 'dependencies': {
+ 'ui:help': (
+ 'Check the documentation for the correct format when '
+ 'defining dependencies.'
+ ),
+ },
+ },
+ 'VALIDATION': [
+ # ensure that start_date <= end_date
+ {
+ 'name': 'less_equal',
+ 'arguments': ['start_date', 'end_date'],
+ 'message': 'End date cannot be before start date',
+ # this is where the error message is shown
+ 'container': 'end_date',
+ },
+ ],
+ # link to the scheduler; this example links to an Airflow pipeline
+ # that uses the query id and the output table as its name
+ 'linkback': (
+ 'https://airflow.example.com/admin/airflow/tree?'
+ 'dag_id=query_${id}_${extra_json.schedule_info.output_table}'
+ ),
}
```
-This feature flag is based on
+This configuration is based on
[react-jsonschema-form](https://github.com/mozilla-services/react-jsonschema-form)
and will add a
-button called “Schedule Query” to SQL Lab. When the button is clicked, a modal
will show up where
+menu item called “Schedule” to SQL Lab. When the menu item is clicked, a modal
will show up where
the user can add the metadata required for scheduling the query.
This information can then be retrieved from the endpoint
`/savedqueryviewapi/api/read` and used to
diff --git
a/superset-frontend/src/SqlLab/components/ScheduleQueryButton/index.tsx
b/superset-frontend/src/SqlLab/components/ScheduleQueryButton/index.tsx
index facb23461c..8da7ab7e66 100644
--- a/superset-frontend/src/SqlLab/components/ScheduleQueryButton/index.tsx
+++ b/superset-frontend/src/SqlLab/components/ScheduleQueryButton/index.tsx
@@ -197,7 +197,7 @@ const ScheduleQueryButton:
FunctionComponent<ScheduleQueryButtonProps> = ({
<StyledJsonSchema>
<SchemaForm
schema={getJSONSchema()}
- uiSchema={getUISchema}
+ uiSchema={getUISchema()}
onSubmit={onScheduleSubmit}
validate={getValidator()}
>
diff --git a/superset/config.py b/superset/config.py
index 9b09c0a1fa..ae6e32a560 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -237,6 +237,9 @@ SHOW_STACKTRACE = True
ENABLE_PROXY_FIX = False
PROXY_FIX_CONFIG = {"x_for": 1, "x_proto": 1, "x_host": 1, "x_port": 1,
"x_prefix": 1}
+# Configuration for scheduling queries from SQL Lab.
+SCHEDULED_QUERIES: Dict[str, Any] = {}
+
# ------------------------------
# GLOBALS FOR APP Builder
# ------------------------------