Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schedule-query): getUISchema function called in SchemaForm component #20256

Merged
merged 32 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e8e1e31
Merge pull request #2 from apache/master
Mar 23, 2022
0720ee6
Merge pull request #3 from apache/master
Mar 28, 2022
0d9405c
Merge pull request #4 from apache/master
Apr 3, 2022
7e4af14
Merge pull request #5 from apache/master
Apr 7, 2022
5938291
Merge pull request #6 from apache/master
Apr 11, 2022
2f039d7
Merge pull request #7 from apache/master
Apr 19, 2022
7f49f3a
Merge pull request #8 from apache/master
Apr 27, 2022
230438e
Merge pull request #9 from apache/master
May 6, 2022
c4debe6
Merge pull request #10 from apache/master
May 11, 2022
6d18661
Revert "Superset - Release and Improvements (12-05-2022)"
RahulRaj97 May 11, 2022
7ffe7dc
Merge pull request #12 from careem/revert-10-master
May 11, 2022
00d8c87
Merge branch 'master' of https://github.com/apache/superset into apac…
May 19, 2022
894c619
merging conflic changes
May 19, 2022
fd1af9a
Merge pull request #14 from careem/apache-new-master
May 19, 2022
9a3ee04
Revert "Revert "Superset - Release and Improvements (12-05-2022)""
May 19, 2022
bf8e88e
fixed breaking changes
May 19, 2022
595e9e6
Merge pull request #16 from careem/apache-latest
May 19, 2022
82e03b9
sync with master
May 19, 2022
6ce772b
Merge pull request #17 from careem/fix-apache-master
May 19, 2022
6c30d85
Merge pull request #18 from apache/master
May 23, 2022
2edf94a
fixed breaking flows
May 30, 2022
ef17cb8
Merge pull request #19 from apache/master
May 30, 2022
00a6937
fixed getUISchema function call
Jun 3, 2022
1be49e1
added default placeholder and updated docs
Jun 4, 2022
23f8812
fixed format and comments
Jun 4, 2022
153fbfd
changed flag to configuration
Jun 21, 2022
0a2735a
fix: indentation of SCHEDULED_QUERIES dict
Jul 1, 2022
f8b1d20
fix: changed intendation for SCHEDULED_QUERIES
Jul 1, 2022
8852b6c
fix: updated docs for SCHEDULED_QUERIES
Jul 1, 2022
58e21fe
fix: replaced button to menu item for SCHEDULED_QUERIES
Jul 1, 2022
6eae6dc
fix: updated docs for SCHEDULED_QUERIES
Jul 1, 2022
d60af23
fix: trailing whitespace
Jul 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 71 additions & 74 deletions docs/docs/installation/alerts-reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const ScheduleQueryButton: FunctionComponent<ScheduleQueryButtonProps> = ({
<StyledJsonSchema>
<SchemaForm
schema={getJSONSchema()}
uiSchema={getUISchema}
uiSchema={getUISchema()}
onSubmit={onScheduleSubmit}
validate={getValidator()}
>
Expand Down
3 changes: 3 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]:
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
# ------------------------------
Expand Down