-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
feat: Scheduling queries from SQL Lab (#7416) #7446
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f5e1dcc
Merge lastest from master into lyft-release-sp8 (#7405)
DiggidyDave bfd685e
feat: see Presto row and array data types (#7391)
khtruong 51c7f92
Incorporate feedback from initial PR (prematurely merged to lyft-rele…
DiggidyDave bbb0b75
feat: view presto row objects in data grid
khtruong ff6c208
fix: address feedback
khtruong b1aface
fix: spacing
khtruong 59a81e1
Workaround for no results returned (#7442)
betodealmeida 2a003c1
feat: view presto row objects in data grid (#7436)
khtruong 90eef51
feat: Scheduling queries from SQL Lab (#7416)
betodealmeida 8e23f90
feat: view presto row objects in data grid
khtruong 4b5e54f
feat: Scheduling queries from SQL Lab (#7416)
betodealmeida File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
superset/assets/src/SqlLab/components/ScheduleQueryButton.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Form from 'react-jsonschema-form'; | ||
import { t } from '@superset-ui/translation'; | ||
|
||
import Button from '../../components/Button'; | ||
import ModalTrigger from '../../components/ModalTrigger'; | ||
|
||
const propTypes = { | ||
defaultLabel: PropTypes.string, | ||
sql: PropTypes.string.isRequired, | ||
schema: PropTypes.string.isRequired, | ||
dbId: PropTypes.number.isRequired, | ||
animation: PropTypes.bool, | ||
onSchedule: PropTypes.func, | ||
}; | ||
const defaultProps = { | ||
defaultLabel: t('Undefined'), | ||
animation: true, | ||
onSchedule: () => {}, | ||
}; | ||
|
||
class ScheduleQueryButton extends React.PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
description: '', | ||
label: props.defaultLabel, | ||
showSchedule: false, | ||
}; | ||
this.toggleSchedule = this.toggleSchedule.bind(this); | ||
this.onSchedule = this.onSchedule.bind(this); | ||
this.onCancel = this.onCancel.bind(this); | ||
this.onLabelChange = this.onLabelChange.bind(this); | ||
this.onDescriptionChange = this.onDescriptionChange.bind(this); | ||
} | ||
onSchedule({ formData }) { | ||
const query = { | ||
label: this.state.label, | ||
description: this.state.description, | ||
db_id: this.props.dbId, | ||
schema: this.props.schema, | ||
sql: this.props.sql, | ||
extra_json: JSON.stringify({ schedule_info: formData }), | ||
}; | ||
this.props.onSchedule(query); | ||
this.saveModal.close(); | ||
} | ||
onCancel() { | ||
this.saveModal.close(); | ||
} | ||
onLabelChange(e) { | ||
this.setState({ label: e.target.value }); | ||
} | ||
onDescriptionChange(e) { | ||
this.setState({ description: e.target.value }); | ||
} | ||
toggleSchedule(e) { | ||
this.setState({ target: e.target, showSchedule: !this.state.showSchedule }); | ||
} | ||
renderModalBody() { | ||
return ( | ||
<Form | ||
schema={window.featureFlags.SCHEDULED_QUERIES.JSONSCHEMA} | ||
uiSchema={window.featureFlags.SCHEDULED_QUERIES.UISCHEMA} | ||
onSubmit={this.onSchedule} | ||
/> | ||
); | ||
} | ||
render() { | ||
return ( | ||
<span className="ScheduleQueryButton"> | ||
<ModalTrigger | ||
ref={(ref) => { this.saveModal = ref; }} | ||
modalTitle={t('Schedule Query')} | ||
modalBody={this.renderModalBody()} | ||
triggerNode={ | ||
<Button bsSize="small" className="toggleSchedule" onClick={this.toggleSchedule}> | ||
<i className="fa fa-calendar" /> {t('Schedule Query')} | ||
</Button> | ||
} | ||
bsSize="medium" | ||
/> | ||
</span> | ||
); | ||
} | ||
} | ||
ScheduleQueryButton.propTypes = propTypes; | ||
ScheduleQueryButton.defaultProps = defaultProps; | ||
|
||
export default ScheduleQueryButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DiggidyDave this logic is problematic. Sql Lab can run async and synchronous queries. For synchronous queries, it will not have a resultsKey.
the new logic will make extra polling happen when user has at least 1 synchronous query (and < 6 hours old). For synchronous queries, results are returned from sql_json request, polling should not happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, my bad. I'll fix it.