2019-01-19 06:18:22 -05:00
<!--
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.
-->
2015-07-20 19:29:16 -04:00
# Contributing
Contributions are welcome and are greatly appreciated! Every
little bit helps, and credit will always be given.
2018-09-19 13:01:51 -04:00
## Table of Contents
2020-02-24 17:31:23 -05:00
- [Contributing ](#contributing )
- [Table of Contents ](#table-of-contents )
- [Orientation ](#orientation )
- [Types of Contributions ](#types-of-contributions )
- [Report Bug ](#report-bug )
- [Submit Ideas or Feature Requests ](#submit-ideas-or-feature-requests )
- [Fix Bugs ](#fix-bugs )
- [Implement Features ](#implement-features )
- [Improve Documentation ](#improve-documentation )
- [Add Translations ](#add-translations )
- [Ask Questions ](#ask-questions )
- [Pull Request Guidelines ](#pull-request-guidelines )
- [Protocol ](#protocol )
- [Authoring ](#authoring )
- [Reviewing ](#reviewing )
- [Merging ](#merging )
- [Post-merge Responsibility ](#post-merge-responsibility )
- [Managing Issues and PRs ](#managing-issues-and-prs )
- [Revert Guidelines ](#revert-guidelines )
- [Setup Local Environment for Development ](#setup-local-environment-for-development )
- [Documentation ](#documentation )
- [Images ](#images )
- [API documentation ](#api-documentation )
- [Flask server ](#flask-server )
- [OS Dependencies ](#os-dependencies )
- [Logging to the browser console ](#logging-to-the-browser-console )
- [Frontend Assets ](#frontend-assets )
- [nvm and node ](#nvm-and-node )
- [Prerequisite ](#prerequisite )
- [Installing Dependencies ](#installing-dependencies )
- [Building ](#building )
- [Docker (docker-compose) ](#docker-docker-compose )
- [Updating NPM packages ](#updating-npm-packages )
- [Feature flags ](#feature-flags )
- [Git Hooks ](#git-hooks )
2018-09-19 13:01:51 -04:00
- [Linting ](#linting )
2020-02-24 17:31:23 -05:00
- [Conventions ](#conventions )
- [Python ](#python )
- [Typing ](#typing )
- [Python ](#python-1 )
- [TypeScript ](#typescript )
- [Testing ](#testing )
- [Python Testing ](#python-testing )
- [Frontend Testing ](#frontend-testing )
- [Integration Testing ](#integration-testing )
- [Translating ](#translating )
- [Enabling language selection ](#enabling-language-selection )
- [Extracting new strings for translation ](#extracting-new-strings-for-translation )
- [Creating a new language dictionary ](#creating-a-new-language-dictionary )
- [Tips ](#tips )
- [Adding a new datasource ](#adding-a-new-datasource )
2020-03-26 19:55:22 -04:00
- [Improving visualizations ](#improving-visualizations )
2020-02-24 17:31:23 -05:00
- [Adding a DB migration ](#adding-a-db-migration )
- [Merging DB migrations ](#merging-db-migrations )
- [SQL Lab Async ](#sql-lab-async )
- [Chart Parameters ](#chart-parameters )
- [Datasource & Chart Type ](#datasource--chart-type )
- [Time ](#time )
- [GROUP BY ](#group-by )
- [NOT GROUPED BY ](#not-grouped-by )
- [Y Axis 1 ](#y-axis-1 )
- [Y Axis 2 ](#y-axis-2 )
- [Query ](#query )
- [Filters Configuration ](#filters-configuration )
- [Options ](#options )
- [Chart Options ](#chart-options )
- [X Axis ](#x-axis )
- [Y Axis ](#y-axis )
- [Other ](#other )
- [Unclassified ](#unclassified )
2015-07-20 19:29:16 -04:00
2019-10-23 00:44:11 -04:00
## Orientation
Here's a list of repositories that contain Superset-related packages:
- [apache/incubator-superset ](https://github.com/apache/incubator-superset )
is the main repository containing the `apache-superset` Python package
distributed on
[pypi ](https://pypi.org/project/apache-superset/ ). This repository
2020-02-24 17:31:23 -05:00
also includes Superset's main TypeScript/JavaScript bundles and react apps under
2020-02-09 20:53:56 -05:00
the [superset-frontend ](https://github.com/apache/incubator-superset/tree/master/superset-frontend )
2019-10-23 00:44:11 -04:00
folder.
- [apache-superset/superset-ui ](https://github.com/apache-superset/superset-ui )
contains core Superset's
[npm packages ](https://github.com/apache-superset/superset-ui/tree/master/packages ).
These packages are shared across the React apps in the main repository,
and in visualization plugins.
- [apache-superset/superset-ui-plugins ](https://github.com/apache-superset/superset-ui-plugins )
contains the code for the default visualizations that ship with Superset
and are maintained by the core community.
- [apache-superset/superset-ui-plugins-deckgl ](https://github.com/apache-superset/superset-ui-plugins-deckgl )
contains the code for the geospatial visualizations that ship with Superset
and are maintained by the core community.
- [github.com/apache-superset ](https://github.com/apache-superset ) is the
Github organization under which we manage Superset-related
small tools, forks and Superset-related experimental ideas.
2015-07-20 19:29:16 -04:00
## Types of Contributions
2019-01-19 06:18:22 -05:00
### Report Bug
2015-07-20 19:29:16 -04:00
2019-01-19 06:18:22 -05:00
The best way to report a bug is to file an issue on GitHub. Please include:
2015-07-20 19:29:16 -04:00
2018-09-19 13:01:51 -04:00
- Your operating system name and version.
2019-01-19 06:18:22 -05:00
- Superset version.
2018-09-19 13:01:51 -04:00
- Detailed steps to reproduce the bug.
2019-01-19 06:18:22 -05:00
- Any details about your local setup that might be helpful in troubleshooting.
2015-07-20 19:29:16 -04:00
2018-09-19 13:01:51 -04:00
When posting Python stack traces, please quote them using
[Markdown blocks ](https://help.github.com/articles/creating-and-highlighting-code-blocks/ ).
2017-06-21 13:12:34 -04:00
2019-01-19 06:18:22 -05:00
### Submit Ideas or Feature Requests
The best way is to file an issue on GitHub:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
For large features or major changes to codebase, please create **Superset Improvement Proposal (SIP)** . See template from [SIP-0 ](https://github.com/apache/incubator-superset/issues/5602 )
2015-07-20 19:29:16 -04:00
### Fix Bugs
2019-10-28 11:49:40 -04:00
Look through the GitHub issues. Issues tagged with `#bug` are
2019-10-30 19:19:16 -04:00
open to whoever wants to implement them.
2015-07-20 19:29:16 -04:00
### Implement Features
2019-01-19 06:18:22 -05:00
Look through the GitHub issues. Issues tagged with
`#feature` is open to whoever wants to implement it.
2015-07-20 19:29:16 -04:00
2018-09-19 13:01:51 -04:00
### Improve Documentation
2015-07-20 19:29:16 -04:00
2016-11-10 02:08:22 -05:00
Superset could always use better documentation,
whether as part of the official Superset docs,
2015-07-20 19:29:16 -04:00
in docstrings, `docs/*.rst` or even on the web as blog posts or
2018-09-19 13:01:51 -04:00
articles. See [Documentation ](#documentation ) for more details.
2015-07-20 19:29:16 -04:00
2018-09-19 13:01:51 -04:00
### Add Translations
2018-08-25 19:31:03 -04:00
2019-07-04 01:33:14 -04:00
If you are proficient in a non-English language, you can help translate
text strings from Superset's UI. You can jump in to the existing
language dictionaries at
`superset/translations/<language_code>/LC_MESSAGES/messages.po` , or
even create a dictionary for a new language altogether.
See [Translating ](#translating ) for more details.
2015-07-20 19:29:16 -04:00
2018-09-19 13:01:51 -04:00
### Ask Questions
2017-11-02 16:49:47 -04:00
2018-09-19 13:01:51 -04:00
There is a dedicated [`apache-superset` tag ](https://stackoverflow.com/questions/tagged/apache-superset ) on [StackOverflow ](https://stackoverflow.com/ ). Please use it when asking questions.
2015-07-20 19:29:16 -04:00
2017-06-04 21:00:33 -04:00
## Pull Request Guidelines
2019-01-19 06:18:22 -05:00
A philosophy we would like to strongly encourage is
> Before creating a PR, create an issue.
The purpose is to separate problem from possible solutions.
**Bug fixes:** If you’ re only fixing a small bug, it’ s fine to submit a pull request right away but we highly recommend to file an issue detailing what you’ re fixing. This is helpful in case we don’ t accept that specific fix but want to keep track of the issue. Please keep in mind that the project maintainers reserve the rights to accept or reject incoming PRs, so it is better to separate the issue and the code to fix it from each other. In some cases, project maintainers may request you to create a separate issue from PR before proceeding.
**Refactor:** For small refactors, it can be a standalone PR itself detailing what you are refactoring and why. If there are concerns, project maintainers may request you to create a `#SIP` for the PR before proceeding.
**Feature/Large changes:** If you intend to change the public API, or make any non-trivial changes to the implementation, we requires you to file a new issue as `#SIP` (Superset Improvement Proposal). This lets us reach an agreement on your proposal before you put significant effort into it. You are welcome to submit a PR along with the SIP (sometimes necessary for demonstration), but we will not review/merge the code until the SIP is approved.
In general, small PRs are always easier to review than large PRs. The best practice is to break your work into smaller independent PRs and refer to the same issue. This will greatly reduce turnaround time.
Finally, never submit a PR that will put master branch in broken state. If the PR is part of multiple PRs to complete a large feature and cannot work on its own, you can create a feature branch and merge all related PRs into the feature branch before creating a PR from feature branch to master.
### Protocol
#### Authoring
- Fill in all sections of the PR template.
- Add prefix `[WIP]` to title if not ready for review (WIP = work-in-progress). We recommend creating a PR with `[WIP]` first and remove it once you have passed CI test and read through your code changes at least once.
- **Screenshots/GIFs:** Changes to user interface require before/after screenshots, or GIF for interactions
- Recommended capture tools ([Kap](https://getkap.co/), [LICEcap ](https://www.cockos.com/licecap/ ), [Skitch ](https://download.cnet.com/Skitch/3000-13455_4-189876.html ))
- If no screenshot is provided, the committers will mark the PR with `need:screenshot` label and will not review until screenshot is provided.
- **Dependencies:** Be careful about adding new dependency and avoid unnecessary dependencies.
- For Python, include it in `setup.py` denoting any specific restrictions and in `requirements.txt` pinned to a specific version which ensures that the application build is deterministic.
2020-02-24 17:31:23 -05:00
- For TypeScript/JavaScript, include new libraries in `package.json`
2019-01-19 06:18:22 -05:00
- **Tests:** The pull request should include tests, either as doctests, unit tests, or both. Make sure to resolve all errors and test failures. See [Testing ](#testing ) for how to run tests.
- **Documentation:** If the pull request adds functionality, the docs should be updated as part of the same PR. Doc string are often sufficient, make sure to follow the sphinx compatible standards.
- **CI:** Reviewers will not review the code until all CI tests are passed. Sometimes there can be flaky tests. You can close and open PR to re-run CI test. Please report if the issue persists. After the CI fix has been deployed to `master` , please rebase your PR.
- **Code coverage:** Please ensure that code coverage does not decrease.
- Remove `[WIP]` when ready for review. Please note that it may be merged soon after approved so please make sure the PR is ready to merge and do not expect more time for post-approval edits.
- If the PR was not ready for review and inactive for > 30 days, we will close it due to inactivity. The author is welcome to re-open and update.
#### Reviewing
- Use constructive tone when writing reviews.
- If there are changes required, state clearly what needs to be done before the PR can be approved.
- If you are asked to update your pull request with some changes there's no need to create a new one. Push your changes to the same branch.
- The committers reserve the right to reject any PR and in some cases may request the author to file an issue.
#### Merging
- At least one approval is required for merging a PR.
- PR is usually left open for at least 24 hours before merging.
- After the PR is merged, [close the corresponding issue(s) ](https://help.github.com/articles/closing-issues-using-keywords/ ).
#### Post-merge Responsibility
- Project maintainers may contact the PR author if new issues are introduced by the PR.
- Project maintainers may revert your changes if a critical issue is found, such as breaking master branch CI.
## Managing Issues and PRs
To handle issues and PRs that are coming in, committers read issues/PRs and flag them with labels to categorize and help contributors spot where to take actions, as contributors usually have different expertises.
Triaging goals
- **For issues:** Categorize, screen issues, flag required actions from authors.
- **For PRs:** Categorize, flag required actions from authors. If PR is ready for review, flag required actions from reviewers.
First, add **Category labels (a.k.a. hash labels)** . Every issue/PR must have one hash label (except spam entry). Labels that begin with `#` defines issue/PR type:
2019-12-18 12:59:42 -05:00
| Label | for Issue | for PR |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `#bug` | Bug report | Bug fix |
| `#code-quality` | Describe problem with code, architecture or productivity | Refactor, tests, tooling |
| `#feature` | New feature request | New feature implementation |
| `#refine` | Propose improvement that does not provide new features and is also not a bug fix nor refactor, such as adjust padding, refine UI style. | Implementation of improvement that does not provide new features and is also not a bug fix nor refactor, such as adjust padding, refine UI style. |
| `#doc` | Documentation | Documentation |
| `#question` | Troubleshooting: Installation, Running locally, Ask how to do something. Can be changed to `#bug` later. | N/A |
| `#SIP` | Superset Improvement Proposal | N/A |
| `#ASF` | Tasks related to Apache Software Foundation policy | Tasks related to Apache Software Foundation policy |
2019-01-19 06:18:22 -05:00
Then add other types of labels as appropriate.
- **Descriptive labels (a.k.a. dot labels):** These labels that begin with `.` describe the details of the issue/PR, such as `.ui` , `.js` , `.install` , `.backend` , etc. Each issue/PR can have zero or more dot labels.
- **Need labels:** These labels have pattern `need:xxx` , which describe the work required to progress, such as `need:rebase` , `need:update` , `need:screenshot` .
- **Risk labels:** These labels have pattern `risk:xxx` , which describe the potential risk on adopting the work, such as `risk:db-migration` . The intention was to better understand the impact and create awareness for PRs that need more rigorous testing.
- **Status labels:** These labels describe the status (`abandoned`, `wontfix` , `cant-reproduce` , etc.) Issue/PRs that are rejected or closed without completion should have one or more status labels.
- **Version labels:** These have the pattern `vx.x` such as `v0.28` . Version labels on issues describe the version the bug was reported on. Version labels on PR describe the first release that will include the PR.
Committers may also update title to reflect the issue/PR content if the author-provided title is not descriptive enough.
If the PR passes CI tests and does not have any `need:` labels, it is ready for review, add label `review` and/or `design-review` .
If an issue/PR has been inactive for >=30 days, it will be closed. If it does not have any status label, add `inactive` .
2017-06-04 21:00:33 -04:00
2020-01-29 20:47:58 -05:00
## Revert Guidelines
Reverting changes that are causing issues in the master branch is a normal and expected part of the development process. In an open source community, the ramifications of a change cannot always be fully understood. With that in mind, here are some considerations to keep in mind when considering a revert:
- **Availability of the PR author:** If the original PR author or the engineer who merged the code is highly available and can provide a fix in a reasonable timeframe, this would counter-indicate reverting.
- **Severity of the issue:** How severe is the problem on master? Is it keeping the project from moving forward? Is there user impact? What percentage of users will experience a problem?
- **Size of the change being reverted:** Reverting a single small PR is a much lower-risk proposition than reverting a massive, multi-PR change.
- **Age of the change being reverted:** Reverting a recently-merged PR will be more acceptable than reverting an older PR. A bug discovered in an older PR is unlikely to be causing widespread serious issues.
- **Risk inherent in reverting:** Will the reversion break critical functionality? Is the medicine more dangerous than the disease?
- **Difficulty of crafting a fix:** In the case of issues with a clear solution, it may be preferable to implement and merge a fix rather than a revert.
Should you decide that reverting is desirable, it is the responsibility of the Contributor performing the revert to:
2020-02-24 17:31:23 -05:00
2020-01-29 20:47:58 -05:00
- **Contact the interested parties:** The PR's author and the engineer who merged the work should both be contacted and informed of the revert.
- **Provide concise reproduction steps:** Ensure that the issue can be clearly understood and duplicated by the original author of the PR.
- **Put the revert through code review:** The revert must be approved by another committer.
2018-12-11 16:45:50 -05:00
## Setup Local Environment for Development
2015-07-20 19:29:16 -04:00
2018-12-11 16:45:50 -05:00
First, [fork the repository on GitHub ](https://help.github.com/articles/about-forks/ ), then clone it. You can clone the main repository directly, but you won't be able to send pull requests.
2018-09-19 13:01:51 -04:00
```bash
git clone git@github.com:your-username/incubator-superset.git
cd incubator-superset
```
### Documentation
The latest documentation and tutorial are available at https://superset.incubator.apache.org/.
2017-01-25 14:41:39 -05:00
Contributing to the official documentation is relatively easy, once you've setup
your environment and done an edit end-to-end. The docs can be found in the
`docs/` subdirectory of the repository, and are written in the
[reStructuredText format ](https://en.wikipedia.org/wiki/ReStructuredText ) (.rst).
If you've written Markdown before, you'll find the reStructuredText format familiar.
Superset uses [Sphinx ](http://www.sphinx-doc.org/en/1.5.1/ ) to convert the rst files
in `docs/` to the final HTML output users see.
2018-03-14 19:50:25 -04:00
Finally, to make changes to the rst files and build the docs using Sphinx,
2017-01-26 12:07:23 -05:00
you'll need to install a handful of dependencies from the repo you cloned:
2017-01-25 14:41:39 -05:00
2018-09-19 13:01:51 -04:00
```bash
pip install -r docs/requirements.txt
```
2017-01-25 14:41:39 -05:00
To get the feel for how to edit and build the docs, let's edit a file, build
the docs and see our changes in action. First, you'll want to
[create a new branch ](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging )
to work on your changes:
2018-09-19 13:01:51 -04:00
```bash
git checkout -b changes-to-docs
```
2017-01-25 14:41:39 -05:00
2018-09-19 13:01:51 -04:00
Now, go ahead and edit one of the files under `docs/` , say `docs/tutorial.rst` - change
it however you want. Check out the
2017-01-25 14:41:39 -05:00
[ReStructuredText Primer ](http://docutils.sourceforge.net/docs/user/rst/quickstart.html )
for a reference on the formatting of the rst files.
2018-09-19 13:01:51 -04:00
Once you've made your changes, run this command to convert the docs into HTML:
2017-01-25 14:41:39 -05:00
2018-09-19 13:01:51 -04:00
```bash
make html
```
2017-01-25 14:41:39 -05:00
You'll see a lot of output as Sphinx handles the conversion. After it's done, the
2018-09-19 13:01:51 -04:00
HTML Sphinx generated should be in `docs/_build/html` . Navigate there
2017-01-25 14:41:39 -05:00
and start a simple web server so we can check out the docs in a browser:
2018-09-19 13:01:51 -04:00
```bash
cd docs/_build/html
2018-12-17 20:20:33 -05:00
python -m http.server # Python2 users should use SimpleHTTPServer
2018-09-19 13:01:51 -04:00
```
2017-01-25 14:41:39 -05:00
This will start a small Python web server listening on port 8000. Point your
2018-09-19 13:01:51 -04:00
browser to http://localhost:8000, find the file
2017-01-25 14:41:39 -05:00
you edited earlier, and check out your changes!
If you've made a change you'd like to contribute to the actual docs, just commit
your code, push your new branch to Github:
2018-09-19 13:01:51 -04:00
```bash
git add docs/tutorial.rst
git commit -m 'Awesome new change to tutorial'
git push origin changes-to-docs
```
2017-01-25 14:41:39 -05:00
Then, [open a pull request ](https://help.github.com/articles/about-pull-requests/ ).
2018-09-19 13:01:51 -04:00
#### Images
2017-01-25 14:41:39 -05:00
If you're adding new images to the documentation, you'll notice that the images
referenced in the rst, e.g.
2020-02-09 20:53:56 -05:00
.. image:: _static/images/tutorial/tutorial_01_sources_database.png
2017-01-25 14:41:39 -05:00
2018-09-19 13:01:51 -04:00
aren't actually stored in that directory. Instead, you should add and commit
2020-02-09 20:53:56 -05:00
images (and any other static assets) to the `superset-frontend/images` directory.
2018-09-19 13:01:51 -04:00
When the docs are deployed to https://superset.incubator.apache.org/, images
2020-02-09 20:53:56 -05:00
are copied from there to the `_static/images` directory, just like they're referenced
2017-01-25 14:41:39 -05:00
in the docs.
2020-02-09 20:53:56 -05:00
For example, the image referenced above actually lives in `superset-frontend/images/tutorial` . Since the image is moved during the documentation build process, the docs reference the image in `_static/images/tutorial` instead.
2017-01-25 14:41:39 -05:00
2018-09-19 13:01:51 -04:00
#### API documentation
2017-01-25 14:41:39 -05:00
2018-09-19 13:01:51 -04:00
Generate the API documentation with:
2015-07-20 19:29:16 -04:00
2018-09-19 13:01:51 -04:00
```bash
pip install -r docs/requirements.txt
python setup.py build_sphinx
```
2016-04-08 20:57:24 -04:00
2018-09-19 13:01:51 -04:00
### Flask server
2016-01-13 12:03:27 -05:00
2019-05-20 20:06:08 -04:00
#### OS Dependencies
2019-06-25 16:34:48 -04:00
Make sure your machine meets the [OS dependencies ](https://superset.incubator.apache.org/installation.html#os-dependencies ) before following these steps.
2019-05-20 20:06:08 -04:00
2019-06-25 16:34:48 -04:00
Developers should use a virtualenv.
2019-05-20 20:06:08 -04:00
2020-03-26 19:55:22 -04:00
```bash
2019-05-20 20:06:08 -04:00
pip install virtualenv
```
Then proceed with:
2016-01-13 12:03:27 -05:00
2018-09-19 13:01:51 -04:00
```bash
# Create a virtual environemnt and activate it (recommended)
2019-01-14 18:35:28 -05:00
virtualenv -p python3 venv # setup a python3.6 virtualenv
2018-09-19 13:01:51 -04:00
source venv/bin/activate
2016-01-13 12:03:27 -05:00
2018-09-19 13:01:51 -04:00
# Install external dependencies
pip install -r requirements.txt
2018-11-01 14:19:35 -04:00
pip install -r requirements-dev.txt
2019-05-20 20:06:08 -04:00
2018-09-19 13:01:51 -04:00
# Install Superset in editable (development) mode
pip install -e .
2015-07-20 19:29:16 -04:00
2019-05-20 20:06:08 -04:00
# Create an admin user in your metadata database
2019-12-07 19:09:14 -05:00
superset fab create-admin
2015-07-20 19:29:16 -04:00
2018-09-19 13:01:51 -04:00
# Initialize the database
superset db upgrade
2016-01-13 12:03:27 -05:00
2018-09-19 13:01:51 -04:00
# Create default roles and permissions
superset init
2016-01-13 12:03:27 -05:00
2018-09-19 13:01:51 -04:00
# Load some data to play with
superset load_examples
2016-01-13 12:03:27 -05:00
2019-05-20 20:06:08 -04:00
# Start the Flask dev web server from inside your virtualenv.
2018-12-11 16:45:50 -05:00
# Note that your page may not have css at this point.
# See instructions below how to build the front-end assets.
2019-05-20 20:06:08 -04:00
FLASK_ENV=development superset run -p 8088 --with-threads --reload --debugger
2018-09-19 13:01:51 -04:00
```
2016-02-27 10:47:56 -05:00
2019-12-18 12:59:42 -05:00
**Note: the FLASK_APP env var should not need to be set, as it's currently controlled
via `.flaskenv` , however if needed, it should be set to `superset.app:create_app()` **
2019-12-06 16:15:12 -05:00
2019-06-09 22:13:43 -04:00
If you have made changes to the FAB-managed templates, which are not built the same way as the newer, React-powered front-end assets, you need to start the app without the `--with-threads` argument like so:
`FLASK_ENV=development superset run -p 8088 --reload --debugger`
2019-05-08 16:05:01 -04:00
#### Logging to the browser console
This feature is only available on Python 3. When debugging your application, you can have the server logs sent directly to the browser console using the [ConsoleLog ](https://github.com/betodealmeida/consolelog ) package. You need to mutate the app, by adding the following to your `config.py` or `superset_config.py` :
```python
from console_log import ConsoleLog
def FLASK_APP_MUTATOR(app):
app.wsgi_app = ConsoleLog(app.wsgi_app, app.logger)
```
Then make sure you run your WSGI server using the right worker type:
```bash
2019-12-06 16:15:12 -05:00
FLASK_ENV=development gunicorn "superset.app:create_app()" -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker" -b 127.0.0.1:8088 --reload
2019-05-08 16:05:01 -04:00
```
You can log anything to the browser console, including objects:
```python
from superset import app
app.logger.error('An exception occurred!')
app.logger.info(form_data)
```
2018-12-11 16:45:50 -05:00
### Frontend Assets
2016-02-27 10:47:56 -05:00
2020-02-24 17:31:23 -05:00
Frontend assets (TypeScript, JavaScript, CSS, and images) must be compiled in order to properly display the web UI. The `superset-frontend` directory contains all NPM-managed front end assets. Note that there are additional frontend assets bundled with Flask-Appbuilder (e.g. jQuery and bootstrap); these are not managed by NPM, and may be phased out in the future.
2016-02-27 10:47:56 -05:00
2019-05-20 20:06:08 -04:00
#### nvm and node
First, be sure you are using recent versions of NodeJS and npm. Using [nvm ](https://github.com/creationix/nvm ) to manage them is recommended. Check the docs at the link to be sure, but at the time of writing the following would install nvm and node:
```bash
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
nvm install node
```
2016-02-27 10:47:56 -05:00
2018-12-11 16:45:50 -05:00
#### Prerequisite
2016-02-27 10:47:56 -05:00
2018-12-11 16:45:50 -05:00
#### Installing Dependencies
2016-02-27 10:47:56 -05:00
2018-12-11 16:45:50 -05:00
Install third-party dependencies listed in `package.json` :
2017-02-16 20:28:35 -05:00
2018-12-11 16:45:50 -05:00
```bash
# From the root of the repository
2020-02-09 20:53:56 -05:00
cd superset-frontend
2016-02-27 10:47:56 -05:00
2018-12-21 13:24:49 -05:00
# Install dependencies from `package-lock.json`
npm ci
2016-02-27 10:47:56 -05:00
```
2018-12-11 16:45:50 -05:00
#### Building
2016-02-27 10:47:56 -05:00
2019-01-19 06:18:22 -05:00
You can run the Webpack dev server (in a separate terminal from Flask), which runs on port 9000 and proxies non-asset requests to the Flask server on port 8088. After pointing your browser to `http://localhost:9000` , updates to asset sources will be reflected in-browser without a refresh.
2018-09-04 13:39:05 -04:00
```bash
2018-09-19 13:01:51 -04:00
# Run the dev server
2018-09-04 13:39:05 -04:00
npm run dev-server
2018-09-19 13:01:51 -04:00
# Run the dev server on a non-default port
2019-12-16 00:51:37 -05:00
npm run dev-server -- --devserverPort=9001
2018-09-04 13:39:05 -04:00
2018-09-19 13:01:51 -04:00
# Run the dev server proxying to a Flask server on a non-default port
2018-09-04 13:39:05 -04:00
npm run dev-server -- --supersetPort=8081
2020-03-17 18:37:07 -04:00
# Or proxy it to a remote backend so you can test frontend changes without
# starting the backend locally
npm run dev-server -- --superset=https://superset-dev.example.com
2018-09-04 13:39:05 -04:00
```
2018-12-11 16:45:50 -05:00
Alternatively you can use one of the following commands.
```bash
# Start a watcher that recompiles your assets as you modify them (but have to manually reload your browser to see changes.)
npm run dev
2020-02-24 17:31:23 -05:00
# Compile the TypeScript/JavaScript and CSS in production/optimized mode for official releases
2018-12-11 16:45:50 -05:00
npm run prod
```
2019-05-20 20:06:08 -04:00
If you run this service from somewhere other than your local machine, you may need to add hostname value to webpack.config.js at .devServer.public specifying the endpoint at which you will access the app. For example: myhost:9001. For convenience you may want to install webpack, webpack-cli and webpack-dev-server globally so that you can run them directly:
```bash
npm install --global webpack webpack-cli webpack-dev-server
```
2019-12-06 16:15:12 -05:00
#### Docker (docker-compose)
2019-12-03 13:37:18 -05:00
See docs [here ](docker/README.md )
2018-12-11 16:45:50 -05:00
#### Updating NPM packages
2018-03-23 18:31:47 -04:00
2018-12-21 13:24:49 -05:00
Use npm in the prescribed way, making sure that
2020-02-09 20:53:56 -05:00
`superset-frontend/package-lock.json` is updated according to `npm` -prescribed
2018-12-21 13:24:49 -05:00
best practices.
2018-03-23 18:31:47 -04:00
2018-10-24 01:33:51 -04:00
#### Feature flags
Superset supports a server-wide feature flag system, which eases the incremental development of features. To add a new feature flag, simply modify `superset_config.py` with something like the following:
2019-12-18 12:59:42 -05:00
2020-02-25 11:44:26 -05:00
```python
2018-10-24 01:33:51 -04:00
FEATURE_FLAGS = {
'SCOPED_FILTER': True,
}
```
2019-12-18 12:59:42 -05:00
2020-02-09 20:53:56 -05:00
If you want to use the same flag in the client code, also add it to the FeatureFlag TypeScript enum in `superset-frontend/src/featureFlags.ts` . For example,
2019-12-18 12:59:42 -05:00
2020-02-25 11:44:26 -05:00
```typescript
2018-10-24 01:33:51 -04:00
export enum FeatureFlag {
SCOPED_FILTER = 'SCOPED_FILTER',
}
```
2019-01-29 23:23:13 -05:00
`superset/config.py` contains `DEFAULT_FEATURE_FLAGS` which will be overwritten by
those specified under FEATURE_FLAGS in `superset_config.py` . For example, `DEFAULT_FEATURE_FLAGS = { 'FOO': True, 'BAR': False }` in `superset/config.py` and `FEATURE_FLAGS = { 'BAR': True, 'BAZ': True }` in `superset_config.py` will result
in combined feature flags of `{ 'FOO': True, 'BAR': True, 'BAZ': True }` .
2019-06-25 16:34:48 -04:00
## Git Hooks
Superset uses Git pre-commit hooks courtesy of [pre-commit ](https://pre-commit.com/ ). To install run the following:
```bash
pip3 install -r requirements-dev.txt
pre-commit install
```
2018-12-11 16:45:50 -05:00
## Linting
Lint the project with:
```bash
# for python
tox -e flake8
2020-02-24 17:31:23 -05:00
# for frontend
2020-02-09 20:53:56 -05:00
cd superset-frontend
2018-12-21 13:24:49 -05:00
npm ci
2018-12-11 16:45:50 -05:00
npm run lint
```
2019-06-25 16:34:48 -04:00
The Python code is auto-formatted using [Black ](https://github.com/python/black ) which
is configured as a pre-commit hook. There are also numerous [editor integrations ](https://black.readthedocs.io/en/stable/editor_integration.html ).
2019-10-18 17:44:27 -04:00
## Conventions
### Python
Parameters in the `config.py` (which are accessible via the Flask app.config dictionary) are assummed to always be defined and thus should be accessed directly via,
```python
blueprints = app.config["BLUEPRINTS"]
```
rather than,
```python
blueprints = app.config.get("BLUEPRINTS")
```
or similar as the later will cause typing issues. The former is of type `List[Callable]` whereas the later is of type `Optional[List[Callable]]` .
2020-02-24 17:31:23 -05:00
## Typing
### Python
To ensure clarity, consistency, all readability, _all_ new functions should use
[type hints ](https://docs.python.org/3/library/typing.html ) and include a
docstring using Sphinx documentation.
Note per [PEP-484 ](https://www.python.org/dev/peps/pep-0484/#exceptions ) no
syntax for listing explicitly raised exceptions is proposed and thus the
recommendation is to put this information in a docstring, i.e.,
```python
import math
from typing import Union
def sqrt(x: Union[float, int]) -> Union[float, int]:
"""
Return the square root of x.
:param x: A number
:returns: The square root of the given number
:raises ValueError: If the number is negative
"""
return math.sqrt(x)
```
### TypeScript
TypeScript is fully supported and is the recommended language for writing all new frontend components. When modifying existing functions/components, migrating to TypeScript is appreciated, but not required. Examples of migrating functions/components to TypeScript can be found in [#9162 ](https://github.com/apache/incubator-superset/pull/9162 ) and [#9180 ](https://github.com/apache/incubator-superset/pull/9180 ).
2016-01-13 12:03:27 -05:00
## Testing
2018-09-19 13:01:51 -04:00
2018-12-11 16:45:50 -05:00
### Python Testing
2019-03-18 02:21:32 -04:00
All python tests are carried out in [tox ](https://tox.readthedocs.io/en/latest/index.html )
2018-12-11 16:45:50 -05:00
a standardized testing framework.
2019-03-18 02:21:32 -04:00
All python tests can be run with any of the tox [environments ](https://tox.readthedocs.io/en/latest/example/basic.html#a-simple-tox-ini-default-environments ), via,
2015-07-20 19:29:16 -04:00
2018-09-19 13:01:51 -04:00
```bash
tox -e < environment >
```
2018-04-10 18:59:44 -04:00
2018-12-11 16:45:50 -05:00
For example,
2017-06-21 15:52:04 -04:00
2018-09-19 13:01:51 -04:00
```bash
tox -e py36
```
2015-07-20 19:29:16 -04:00
2018-04-10 18:59:44 -04:00
Alternatively, you can run all tests in a single file via,
2018-03-14 19:50:25 -04:00
2018-09-19 13:01:51 -04:00
```bash
tox -e < environment > -- tests/test_file.py
```
2017-10-12 23:53:37 -04:00
2018-04-10 18:59:44 -04:00
or for a specific test via,
2018-03-14 19:50:25 -04:00
2018-09-19 13:01:51 -04:00
```bash
tox -e < environment > -- tests/test_file.py:TestClassName.test_method_name
```
2018-04-10 18:59:44 -04:00
Note that the test environment uses a temporary directory for defining the
SQLite databases which will be cleared each time before the group of test
commands are invoked.
2015-07-20 19:29:16 -04:00
2020-02-24 17:31:23 -05:00
### Frontend Testing
2018-09-19 13:01:51 -04:00
2020-02-24 17:31:23 -05:00
We use [Jest ](https://jestjs.io/ ) and [Enzyme ](https://airbnb.io/enzyme/ ) to test TypeScript/JavaScript. Tests can be run with:
2016-07-19 19:14:04 -04:00
2018-09-19 13:01:51 -04:00
```bash
2020-02-09 20:53:56 -05:00
cd superset-frontend
2018-09-19 13:01:51 -04:00
npm run test
```
2018-12-11 16:45:50 -05:00
### Integration Testing
2016-07-19 19:14:04 -04:00
2018-09-07 13:26:51 -04:00
We use [Cypress ](https://www.cypress.io/ ) for integration tests. Tests can be run by `tox -e cypress` . To open Cypress and explore tests first setup and run test server:
2018-09-19 13:01:51 -04:00
```bash
export SUPERSET_CONFIG=tests.superset_test_config
superset db upgrade
superset init
superset load_test_users
superset load_examples
2019-05-20 20:06:08 -04:00
superset run --port 8081
2018-09-19 13:01:51 -04:00
```
2018-09-07 13:26:51 -04:00
2018-09-19 13:01:51 -04:00
Run Cypress tests:
2018-09-07 13:26:51 -04:00
2018-09-19 13:01:51 -04:00
```bash
2020-02-09 20:53:56 -05:00
cd superset-frontend
2018-09-19 13:01:51 -04:00
npm run build
2019-12-18 12:59:42 -05:00
cd cypress-base
npm install
2018-09-19 13:01:51 -04:00
npm run cypress run
Fix control validation handling (#7231)
Fixes a series of unexpected things around control validation.
* when a chart opens in a state where a control is invalid, it still
runs the query, and sometimes gets stuck in what appears to be a 'running'
state. After this change, no query is run, and a warning is displayed
in the chart panel body, just like any other error would
* validation used to be done in the <Control> component and alter the
redux store as it went. Clearly this is not the right approach, now
validation occurs on loading the initial redux state, as well as in
the reducer when controls are changed
* currently, when going from a invalid control state to a valid one
(user addresses what is needed), it auto-triggers a query which can be
unexpected. After this change, the error message disappears, and the
"Run Query" overlay gets displayed
* when changing viz type, it's common to get new validation
errors, and currently when that occurs it will still go ahead and run
a query with invalid inputs, which often results in errors
that are not well handled, since much of the logic
assumes control-validated input.
* prettier control validation messages
(cherry picked from commit a3212eba5df95bca834d8d6d98c11d522d9172f3)
2019-04-18 14:36:38 -04:00
# run tests from a specific file
npm run cypress run -- --spec cypress/integration/explore/link.test.js
# run specific file with video capture
npm run cypress run -- --spec cypress/integration/dashboard/index.test.js --config video=true
2019-12-18 12:59:42 -05:00
# to open the cypress ui
npm run cypress open
2018-09-19 13:01:51 -04:00
```
2018-09-07 13:26:51 -04:00
2020-02-09 20:53:56 -05:00
See [`superset-frontend/cypress_build.sh` ](https://github.com/apache/incubator-superset/blob/master/superset-frontend/cypress_build.sh ).
2019-05-20 20:06:08 -04:00
2018-09-19 13:01:51 -04:00
## Translating
2016-03-05 15:41:22 -05:00
2019-07-04 01:33:14 -04:00
We use [Babel ](http://babel.pocoo.org/en/latest/ ) to translate Superset.
In Python files, we import the magic `_` function using:
2015-07-20 19:29:16 -04:00
2018-09-19 13:01:51 -04:00
```python
from flask_babel import lazy_gettext as _
```
2016-05-02 13:50:23 -04:00
2019-07-04 01:33:14 -04:00
then wrap our translatable strings with it, e.g. `_('Translate me')` .
During extraction, string literals passed to `_` will be added to the
generated `.po` file for each language for later translation.
2016-05-02 13:50:23 -04:00
2019-07-04 01:33:14 -04:00
At runtime, the `_` function will return the translation of the given
string for the current language, or the given string itself
if no translation is available.
2020-02-24 17:31:23 -05:00
In TypeScript/JavaScript, the technique is similar:
2019-07-04 01:33:14 -04:00
we import `t` (simple translation), `tn` (translation containing a number).
js translation -- performance improvment (#3390)
* Chinese page
* Using react-intl-universal to improve multi language in react page
* Using react-intl-universal to improve multi language in react page
* react_intl_universal
* change
* change
* change
* change
* change
* change
* change
* merge
* multiple page in js
* merge
* merge
* merge
* merge
* Js Translations
* JS Translation
* JS Translations
* Js translation
* JS translations
* JS translations
* Js translaion
* JS en Translation
* JS Translation
* upgrade document
Fixing the damn build (#3179)
* Fixing the build
* Going deeper
[bugfix] only filterable columns should show up in FilterBox list (#3105)
* [bugfix] only filterable columns should show up in FilterBox list
* Touchups
Datasource cannot be empty (#3035)
add title description to model view (#3045)
* add title description to model view
* add missing import
Add 'show/hide totals' option to pivot table vis (#3101)
[bugfix] numeric value for date fields in table viz (#3036)
Bug was present only when using the NOT GROUPED BY option
fixes https://github.com/ApacheInfra/superset/issues/3027
fix hive.fetch_logs (#2968)
add Zalando to the list of organizations (#3171)
docs: fixup installation examples code indentation (#3169)
[bugfix] fix bar order (#3180)
[bugfix] visualize flow error: 'Metric x is not valid' (#3181)
The metric name in the frontend doesn't match the one generated on the
backend. It turns out the explore view will default to the first
metric so specifying one isn't needed.
Fix the segment interval for pulling metadata (#3174)
The end of the interval would be on the truncated today date, which
means that you will exclude today. If your realtime ingestion job
runs shorter than a day, the metadata cannot be pulled from the
druid cluster.
Bump cryptography to 1.9 (#3065)
As 1.7.2 doesn't compile here with openssl 1.1.0f
Escaping the user's SQL in the explore view (#3186)
* Escaping the user's SQL in the explore view
When executing SQL from SQL Lab, we use a lower level API to the
database which doesn't require escaping the SQL. When going through
the explore view, the stack chain leading to the same method may need
escaping depending on how the DBAPI driver is written, and that is the
case for Presto (and perhaps other drivers).
* Using regex to avoid doubling doubles
[sqllab] improve Hive support (#3187)
* [sqllab] improve Hive support
* Fix "Transport not open" bug
* Getting progress bar to show
* Bump pyhive to 0.4.0
* Getting [Track Job] button to show
* Fix testzz
Add BigQuery engine specifications (#3193)
As contributed by @mxmzdlv on issue #945
[bugfix] fix merge conflict that broke Hive support (#3196)
Adding 'apache' to docs (#3194)
[druid] Allow custom druid postaggregators (#3146)
* [druid] Allow custom druid postaggregators
Also, fix the postaggregation for approxHistogram quantiles so it adds
the dependent field and that can show up in the graphs/tables.
In general, postAggregators add significant power, we should probably
support including custom postAggregators. Plywood has standard
postAggregators here, and a customAggregator escape hatch that allows
you to define custom postAggregators.
This commit adds a similar capability for Superset and a additional
field/fields/fieldName breakdown of the typical naming for dependent
aggregations, which should make it significantly easier to develop
approxHistogram and custom postAggregation-required dashboards.
* [druid] Minor style cleanup in tests file.
* [druid] Apply code review suggestions
* break out CustomPostAggregator into separate class. This just cleans
up the creation of the postaggregator a little bit.
* minor style issues.
* move the function around so the git diff is more readable
add combine config for metrics in pivot table (#3086)
* add combine config for metrics in pivot table
* change method to stack/unstack
* update backendSync
Autofocus search input in VizTypeControl modal onEnter (#2929)
Speed up JS build time (#3203)
Also bumping a few related libs
JS Translation
JS translations
js translation
fix issue 3204 (#3205)
[bugfix] capture Hive job_id pre-url transformation (#3213)
js translation
fix issue 3204 (#3205)
[bugfix] capture Hive job_id pre-url transformation (#3213)
[docs] update url in CONTRIBUTING.md (#3212)
[sqllab/cosmetics] add margin-top for labels in query history (#3222)
[explore] nvd3 sort values in rich tooltip (#3197)
[sqllab] fix UI shows 'The query returned no results' momentarily (#3214)
this is visible when running async queries between the fetching and
success state as the rows are getting cached in the component
[explore] DatasourceControl to pick datasource in modal (#3210)
* [explore] DatasourceControl to pick datasource in modal
Makes it easier to change datasource, also makes it such that the list
of all datasources doesn't need to be loaded upfront.
* Adding more metadata
* Js translation
* js tran
* js trans
* js trans
* js tran
* js trans
* js trans
* js tran
* js translation
* js trans
* js translation
* try load language pack async
* Backend translations things
* create language pack inside common data
* performance improvement for js i18n.
- js bundle should not contain localized content
- we populate translation content from server-side, in boostrap.common.language_pack
- in client-side, use promise to wrap around translation content. text will be translated after translation content arrived/parsed.
- fix linting
* fix Timer unit test
* 1. add global hook for all tests, to make translation pack avaialble before each test starts.
2. fix unit test for Timer component
3. remove noused method get_locale, and modules
4. fix page reload after user change page language
* parse and build i18n dictionary as a module
* fix sync-backend task, which should run without DOM
2017-09-20 15:37:33 -04:00
2018-09-19 13:01:51 -04:00
```javascript
2020-03-26 19:55:22 -04:00
import { t, tn } from '@superset-ui/translation';
2018-09-19 13:01:51 -04:00
```
2016-05-02 13:50:23 -04:00
2018-09-19 13:01:51 -04:00
### Enabling language selection
2016-05-02 13:50:23 -04:00
2018-09-19 13:01:51 -04:00
Add the `LANGUAGES` variable to your `superset_config.py` . Having more than one
option inside will add a language selection dropdown to the UI on the right side
of the navigation bar.
2016-05-02 13:50:23 -04:00
2018-09-19 13:01:51 -04:00
```python
LANGUAGES = {
'en': {'flag': 'us', 'name': 'English'},
'fr': {'flag': 'fr', 'name': 'French'},
'zh': {'flag': 'cn', 'name': 'Chinese'},
}
```
2016-05-02 13:50:23 -04:00
2018-09-19 13:01:51 -04:00
### Extracting new strings for translation
2016-05-02 13:50:23 -04:00
2018-09-19 13:01:51 -04:00
```bash
2019-06-07 01:15:00 -04:00
flask fab babel-extract --target superset/translations --output superset/translations/messages.pot --config superset/translations/babel.cfg -k _ -k __ -k t -k tn -k tct
2018-09-19 13:01:51 -04:00
```
2016-05-02 13:50:23 -04:00
You can then translate the strings gathered in files located under
2019-01-19 06:18:22 -05:00
`superset/translation` , where there's one per language. You can use [Poedit ](https://poedit.net/features )
2019-01-14 13:48:12 -05:00
to translate the `po` file more conveniently.
There are some [tutorials in the wiki ](https://wiki.lxde.org/en/Translate_*.po_files_with_Poedit ).
For the translations to take effect:
2016-05-02 13:50:23 -04:00
2018-09-19 13:01:51 -04:00
```bash
# In the case of JS translation, we need to convert the PO file into a JSON file, and we need the global download of the npm package po2json.
npm install -g po2json
2019-06-07 01:15:00 -04:00
flask fab babel-compile --target superset/translations
2018-09-19 13:01:51 -04:00
# Convert the en PO file into a JSON file
po2json -d superset -f jed1.x superset/translations/en/LC_MESSAGES/messages.po superset/translations/en/LC_MESSAGES/messages.json
```
2016-09-21 12:52:05 -04:00
2018-09-19 13:01:51 -04:00
If you get errors running `po2json` , you might be running the Ubuntu package with the same
name, rather than the NodeJS package (they have a different format for the arguments). If
there is a conflict, you may need to update your `PATH` environment variable or fully qualify
the executable path (e.g. `/usr/local/bin/po2json` instead of `po2json` ).
2019-01-14 13:48:12 -05:00
If you get a lot of `[null,***]` in `messages.json` , just delete all the `null,` .
For example, `"year":["年"]` is correct while `"year":[null,"年"]` is incorrect.
js translation -- performance improvment (#3390)
* Chinese page
* Using react-intl-universal to improve multi language in react page
* Using react-intl-universal to improve multi language in react page
* react_intl_universal
* change
* change
* change
* change
* change
* change
* change
* merge
* multiple page in js
* merge
* merge
* merge
* merge
* Js Translations
* JS Translation
* JS Translations
* Js translation
* JS translations
* JS translations
* Js translaion
* JS en Translation
* JS Translation
* upgrade document
Fixing the damn build (#3179)
* Fixing the build
* Going deeper
[bugfix] only filterable columns should show up in FilterBox list (#3105)
* [bugfix] only filterable columns should show up in FilterBox list
* Touchups
Datasource cannot be empty (#3035)
add title description to model view (#3045)
* add title description to model view
* add missing import
Add 'show/hide totals' option to pivot table vis (#3101)
[bugfix] numeric value for date fields in table viz (#3036)
Bug was present only when using the NOT GROUPED BY option
fixes https://github.com/ApacheInfra/superset/issues/3027
fix hive.fetch_logs (#2968)
add Zalando to the list of organizations (#3171)
docs: fixup installation examples code indentation (#3169)
[bugfix] fix bar order (#3180)
[bugfix] visualize flow error: 'Metric x is not valid' (#3181)
The metric name in the frontend doesn't match the one generated on the
backend. It turns out the explore view will default to the first
metric so specifying one isn't needed.
Fix the segment interval for pulling metadata (#3174)
The end of the interval would be on the truncated today date, which
means that you will exclude today. If your realtime ingestion job
runs shorter than a day, the metadata cannot be pulled from the
druid cluster.
Bump cryptography to 1.9 (#3065)
As 1.7.2 doesn't compile here with openssl 1.1.0f
Escaping the user's SQL in the explore view (#3186)
* Escaping the user's SQL in the explore view
When executing SQL from SQL Lab, we use a lower level API to the
database which doesn't require escaping the SQL. When going through
the explore view, the stack chain leading to the same method may need
escaping depending on how the DBAPI driver is written, and that is the
case for Presto (and perhaps other drivers).
* Using regex to avoid doubling doubles
[sqllab] improve Hive support (#3187)
* [sqllab] improve Hive support
* Fix "Transport not open" bug
* Getting progress bar to show
* Bump pyhive to 0.4.0
* Getting [Track Job] button to show
* Fix testzz
Add BigQuery engine specifications (#3193)
As contributed by @mxmzdlv on issue #945
[bugfix] fix merge conflict that broke Hive support (#3196)
Adding 'apache' to docs (#3194)
[druid] Allow custom druid postaggregators (#3146)
* [druid] Allow custom druid postaggregators
Also, fix the postaggregation for approxHistogram quantiles so it adds
the dependent field and that can show up in the graphs/tables.
In general, postAggregators add significant power, we should probably
support including custom postAggregators. Plywood has standard
postAggregators here, and a customAggregator escape hatch that allows
you to define custom postAggregators.
This commit adds a similar capability for Superset and a additional
field/fields/fieldName breakdown of the typical naming for dependent
aggregations, which should make it significantly easier to develop
approxHistogram and custom postAggregation-required dashboards.
* [druid] Minor style cleanup in tests file.
* [druid] Apply code review suggestions
* break out CustomPostAggregator into separate class. This just cleans
up the creation of the postaggregator a little bit.
* minor style issues.
* move the function around so the git diff is more readable
add combine config for metrics in pivot table (#3086)
* add combine config for metrics in pivot table
* change method to stack/unstack
* update backendSync
Autofocus search input in VizTypeControl modal onEnter (#2929)
Speed up JS build time (#3203)
Also bumping a few related libs
JS Translation
JS translations
js translation
fix issue 3204 (#3205)
[bugfix] capture Hive job_id pre-url transformation (#3213)
js translation
fix issue 3204 (#3205)
[bugfix] capture Hive job_id pre-url transformation (#3213)
[docs] update url in CONTRIBUTING.md (#3212)
[sqllab/cosmetics] add margin-top for labels in query history (#3222)
[explore] nvd3 sort values in rich tooltip (#3197)
[sqllab] fix UI shows 'The query returned no results' momentarily (#3214)
this is visible when running async queries between the fetching and
success state as the rows are getting cached in the component
[explore] DatasourceControl to pick datasource in modal (#3210)
* [explore] DatasourceControl to pick datasource in modal
Makes it easier to change datasource, also makes it such that the list
of all datasources doesn't need to be loaded upfront.
* Adding more metadata
* Js translation
* js tran
* js trans
* js trans
* js tran
* js trans
* js trans
* js tran
* js translation
* js trans
* js translation
* try load language pack async
* Backend translations things
* create language pack inside common data
* performance improvement for js i18n.
- js bundle should not contain localized content
- we populate translation content from server-side, in boostrap.common.language_pack
- in client-side, use promise to wrap around translation content. text will be translated after translation content arrived/parsed.
- fix linting
* fix Timer unit test
* 1. add global hook for all tests, to make translation pack avaialble before each test starts.
2. fix unit test for Timer component
3. remove noused method get_locale, and modules
4. fix page reload after user change page language
* parse and build i18n dictionary as a module
* fix sync-backend task, which should run without DOM
2017-09-20 15:37:33 -04:00
2018-09-19 13:01:51 -04:00
### Creating a new language dictionary
js translation -- performance improvment (#3390)
* Chinese page
* Using react-intl-universal to improve multi language in react page
* Using react-intl-universal to improve multi language in react page
* react_intl_universal
* change
* change
* change
* change
* change
* change
* change
* merge
* multiple page in js
* merge
* merge
* merge
* merge
* Js Translations
* JS Translation
* JS Translations
* Js translation
* JS translations
* JS translations
* Js translaion
* JS en Translation
* JS Translation
* upgrade document
Fixing the damn build (#3179)
* Fixing the build
* Going deeper
[bugfix] only filterable columns should show up in FilterBox list (#3105)
* [bugfix] only filterable columns should show up in FilterBox list
* Touchups
Datasource cannot be empty (#3035)
add title description to model view (#3045)
* add title description to model view
* add missing import
Add 'show/hide totals' option to pivot table vis (#3101)
[bugfix] numeric value for date fields in table viz (#3036)
Bug was present only when using the NOT GROUPED BY option
fixes https://github.com/ApacheInfra/superset/issues/3027
fix hive.fetch_logs (#2968)
add Zalando to the list of organizations (#3171)
docs: fixup installation examples code indentation (#3169)
[bugfix] fix bar order (#3180)
[bugfix] visualize flow error: 'Metric x is not valid' (#3181)
The metric name in the frontend doesn't match the one generated on the
backend. It turns out the explore view will default to the first
metric so specifying one isn't needed.
Fix the segment interval for pulling metadata (#3174)
The end of the interval would be on the truncated today date, which
means that you will exclude today. If your realtime ingestion job
runs shorter than a day, the metadata cannot be pulled from the
druid cluster.
Bump cryptography to 1.9 (#3065)
As 1.7.2 doesn't compile here with openssl 1.1.0f
Escaping the user's SQL in the explore view (#3186)
* Escaping the user's SQL in the explore view
When executing SQL from SQL Lab, we use a lower level API to the
database which doesn't require escaping the SQL. When going through
the explore view, the stack chain leading to the same method may need
escaping depending on how the DBAPI driver is written, and that is the
case for Presto (and perhaps other drivers).
* Using regex to avoid doubling doubles
[sqllab] improve Hive support (#3187)
* [sqllab] improve Hive support
* Fix "Transport not open" bug
* Getting progress bar to show
* Bump pyhive to 0.4.0
* Getting [Track Job] button to show
* Fix testzz
Add BigQuery engine specifications (#3193)
As contributed by @mxmzdlv on issue #945
[bugfix] fix merge conflict that broke Hive support (#3196)
Adding 'apache' to docs (#3194)
[druid] Allow custom druid postaggregators (#3146)
* [druid] Allow custom druid postaggregators
Also, fix the postaggregation for approxHistogram quantiles so it adds
the dependent field and that can show up in the graphs/tables.
In general, postAggregators add significant power, we should probably
support including custom postAggregators. Plywood has standard
postAggregators here, and a customAggregator escape hatch that allows
you to define custom postAggregators.
This commit adds a similar capability for Superset and a additional
field/fields/fieldName breakdown of the typical naming for dependent
aggregations, which should make it significantly easier to develop
approxHistogram and custom postAggregation-required dashboards.
* [druid] Minor style cleanup in tests file.
* [druid] Apply code review suggestions
* break out CustomPostAggregator into separate class. This just cleans
up the creation of the postaggregator a little bit.
* minor style issues.
* move the function around so the git diff is more readable
add combine config for metrics in pivot table (#3086)
* add combine config for metrics in pivot table
* change method to stack/unstack
* update backendSync
Autofocus search input in VizTypeControl modal onEnter (#2929)
Speed up JS build time (#3203)
Also bumping a few related libs
JS Translation
JS translations
js translation
fix issue 3204 (#3205)
[bugfix] capture Hive job_id pre-url transformation (#3213)
js translation
fix issue 3204 (#3205)
[bugfix] capture Hive job_id pre-url transformation (#3213)
[docs] update url in CONTRIBUTING.md (#3212)
[sqllab/cosmetics] add margin-top for labels in query history (#3222)
[explore] nvd3 sort values in rich tooltip (#3197)
[sqllab] fix UI shows 'The query returned no results' momentarily (#3214)
this is visible when running async queries between the fetching and
success state as the rows are getting cached in the component
[explore] DatasourceControl to pick datasource in modal (#3210)
* [explore] DatasourceControl to pick datasource in modal
Makes it easier to change datasource, also makes it such that the list
of all datasources doesn't need to be loaded upfront.
* Adding more metadata
* Js translation
* js tran
* js trans
* js trans
* js tran
* js trans
* js trans
* js tran
* js translation
* js trans
* js translation
* try load language pack async
* Backend translations things
* create language pack inside common data
* performance improvement for js i18n.
- js bundle should not contain localized content
- we populate translation content from server-side, in boostrap.common.language_pack
- in client-side, use promise to wrap around translation content. text will be translated after translation content arrived/parsed.
- fix linting
* fix Timer unit test
* 1. add global hook for all tests, to make translation pack avaialble before each test starts.
2. fix unit test for Timer component
3. remove noused method get_locale, and modules
4. fix page reload after user change page language
* parse and build i18n dictionary as a module
* fix sync-backend task, which should run without DOM
2017-09-20 15:37:33 -04:00
2018-09-19 13:01:51 -04:00
To create a dictionary for a new language, run the following, where `LANGUAGE_CODE` is replaced with
the language code for your target language, e.g. `es` (see [Flask AppBuilder i18n documentation ](https://flask-appbuilder.readthedocs.io/en/latest/i18n.html ) for more details):
js translation -- performance improvment (#3390)
* Chinese page
* Using react-intl-universal to improve multi language in react page
* Using react-intl-universal to improve multi language in react page
* react_intl_universal
* change
* change
* change
* change
* change
* change
* change
* merge
* multiple page in js
* merge
* merge
* merge
* merge
* Js Translations
* JS Translation
* JS Translations
* Js translation
* JS translations
* JS translations
* Js translaion
* JS en Translation
* JS Translation
* upgrade document
Fixing the damn build (#3179)
* Fixing the build
* Going deeper
[bugfix] only filterable columns should show up in FilterBox list (#3105)
* [bugfix] only filterable columns should show up in FilterBox list
* Touchups
Datasource cannot be empty (#3035)
add title description to model view (#3045)
* add title description to model view
* add missing import
Add 'show/hide totals' option to pivot table vis (#3101)
[bugfix] numeric value for date fields in table viz (#3036)
Bug was present only when using the NOT GROUPED BY option
fixes https://github.com/ApacheInfra/superset/issues/3027
fix hive.fetch_logs (#2968)
add Zalando to the list of organizations (#3171)
docs: fixup installation examples code indentation (#3169)
[bugfix] fix bar order (#3180)
[bugfix] visualize flow error: 'Metric x is not valid' (#3181)
The metric name in the frontend doesn't match the one generated on the
backend. It turns out the explore view will default to the first
metric so specifying one isn't needed.
Fix the segment interval for pulling metadata (#3174)
The end of the interval would be on the truncated today date, which
means that you will exclude today. If your realtime ingestion job
runs shorter than a day, the metadata cannot be pulled from the
druid cluster.
Bump cryptography to 1.9 (#3065)
As 1.7.2 doesn't compile here with openssl 1.1.0f
Escaping the user's SQL in the explore view (#3186)
* Escaping the user's SQL in the explore view
When executing SQL from SQL Lab, we use a lower level API to the
database which doesn't require escaping the SQL. When going through
the explore view, the stack chain leading to the same method may need
escaping depending on how the DBAPI driver is written, and that is the
case for Presto (and perhaps other drivers).
* Using regex to avoid doubling doubles
[sqllab] improve Hive support (#3187)
* [sqllab] improve Hive support
* Fix "Transport not open" bug
* Getting progress bar to show
* Bump pyhive to 0.4.0
* Getting [Track Job] button to show
* Fix testzz
Add BigQuery engine specifications (#3193)
As contributed by @mxmzdlv on issue #945
[bugfix] fix merge conflict that broke Hive support (#3196)
Adding 'apache' to docs (#3194)
[druid] Allow custom druid postaggregators (#3146)
* [druid] Allow custom druid postaggregators
Also, fix the postaggregation for approxHistogram quantiles so it adds
the dependent field and that can show up in the graphs/tables.
In general, postAggregators add significant power, we should probably
support including custom postAggregators. Plywood has standard
postAggregators here, and a customAggregator escape hatch that allows
you to define custom postAggregators.
This commit adds a similar capability for Superset and a additional
field/fields/fieldName breakdown of the typical naming for dependent
aggregations, which should make it significantly easier to develop
approxHistogram and custom postAggregation-required dashboards.
* [druid] Minor style cleanup in tests file.
* [druid] Apply code review suggestions
* break out CustomPostAggregator into separate class. This just cleans
up the creation of the postaggregator a little bit.
* minor style issues.
* move the function around so the git diff is more readable
add combine config for metrics in pivot table (#3086)
* add combine config for metrics in pivot table
* change method to stack/unstack
* update backendSync
Autofocus search input in VizTypeControl modal onEnter (#2929)
Speed up JS build time (#3203)
Also bumping a few related libs
JS Translation
JS translations
js translation
fix issue 3204 (#3205)
[bugfix] capture Hive job_id pre-url transformation (#3213)
js translation
fix issue 3204 (#3205)
[bugfix] capture Hive job_id pre-url transformation (#3213)
[docs] update url in CONTRIBUTING.md (#3212)
[sqllab/cosmetics] add margin-top for labels in query history (#3222)
[explore] nvd3 sort values in rich tooltip (#3197)
[sqllab] fix UI shows 'The query returned no results' momentarily (#3214)
this is visible when running async queries between the fetching and
success state as the rows are getting cached in the component
[explore] DatasourceControl to pick datasource in modal (#3210)
* [explore] DatasourceControl to pick datasource in modal
Makes it easier to change datasource, also makes it such that the list
of all datasources doesn't need to be loaded upfront.
* Adding more metadata
* Js translation
* js tran
* js trans
* js trans
* js tran
* js trans
* js trans
* js tran
* js translation
* js trans
* js translation
* try load language pack async
* Backend translations things
* create language pack inside common data
* performance improvement for js i18n.
- js bundle should not contain localized content
- we populate translation content from server-side, in boostrap.common.language_pack
- in client-side, use promise to wrap around translation content. text will be translated after translation content arrived/parsed.
- fix linting
* fix Timer unit test
* 1. add global hook for all tests, to make translation pack avaialble before each test starts.
2. fix unit test for Timer component
3. remove noused method get_locale, and modules
4. fix page reload after user change page language
* parse and build i18n dictionary as a module
* fix sync-backend task, which should run without DOM
2017-09-20 15:37:33 -04:00
2018-09-19 13:01:51 -04:00
```bash
pip install -r superset/translations/requirements.txt
pybabel init -i superset/translations/messages.pot -d superset/translations -l LANGUAGE_CODE
```
2016-09-21 12:52:05 -04:00
2018-09-19 13:01:51 -04:00
Then, [extract strings for the new language ](#extracting-new-strings-for-translation ).
2017-11-01 23:13:22 -04:00
2018-09-19 13:01:51 -04:00
## Tips
### Adding a new datasource
2016-09-21 12:52:05 -04:00
2016-11-10 02:08:22 -05:00
1. Create Models and Views for the datasource, add them under superset folder, like a new my_models.py
2019-12-18 12:59:42 -05:00
with models for cluster, datasources, columns and metrics and my_views.py with clustermodelview
and datasourcemodelview.
2016-09-21 12:52:05 -04:00
2018-09-19 13:01:51 -04:00
1. Create DB migration files for the new models
2016-09-21 12:52:05 -04:00
2018-09-19 13:01:51 -04:00
1. Specify this variable to add the datasource model and from which module it is from in config.py:
2016-09-21 12:52:05 -04:00
2019-12-18 12:59:42 -05:00
For example:
2016-09-21 12:52:05 -04:00
2019-12-18 12:59:42 -05:00
```python
ADDITIONAL_MODULE_DS_MAP = {'superset.my_models': ['MyDatasource', 'MyOtherDatasource']}
```
2016-09-21 12:52:05 -04:00
2019-12-18 12:59:42 -05:00
This means it'll register MyDatasource and MyOtherDatasource in superset.my_models module in the source registry.
2017-06-22 15:37:22 -04:00
2020-03-26 19:55:22 -04:00
### Improving visualizations
Superset is working towards a plugin system where new visualizations can be installed as optional npm packages. To achieve this goal, we are not accepting pull requests for new community-contributed visualization types at the moment. However, bugfixes for current visualizations are welcome. To edit the frontend code for visualizations, you will have to check out a copy of [apache-superset/superset-ui-plugins ](https://github.com/apache-superset/superset-ui-plugins ):
```bash
git clone https://github.com/apache-superset/superset-ui-plugins.git
yarn & & yarn build
```
Then use `npm link` to create a symlink of the source code in `superset-frontend/node_modules` :
```bash
cd incubator-superset/superset-frontend
npm link ../../superset-ui-plugins/packages/superset-ui-[PLUGIN NAME]
# Or to link all plugin packages:
# npm link ../../superset-ui-plugins/packages/*
# Start developing
npm run dev-server
```
When plugin packages are linked with `npm link` , the dev server will automatically load files from the plugin's `/src` directory.
2017-06-22 15:37:22 -04:00
2020-03-26 19:55:22 -04:00
Note that every time you do `npm install` , you will lose the symlink(s) and may have to run `npm link` again.
2017-08-15 19:37:40 -04:00
2018-09-19 13:01:51 -04:00
### Adding a DB migration
2017-08-15 19:37:40 -04:00
2018-09-19 13:01:51 -04:00
1. Alter the model you want to change. This example will add a `Column` Annotations model.
2017-08-15 19:37:40 -04:00
2019-12-18 12:59:42 -05:00
[Example commit ](https://github.com/apache/incubator-superset/commit/6c25f549384d7c2fc288451222e50493a7b14104 )
2017-08-15 19:37:40 -04:00
2018-09-19 13:01:51 -04:00
1. Generate the migration file
2017-08-15 19:37:40 -04:00
2019-12-18 12:59:42 -05:00
```bash
superset db migrate -m 'add_metadata_column_to_annotation_model.py'
```
2017-08-15 19:37:40 -04:00
2019-12-18 12:59:42 -05:00
This will generate a file in `migrations/version/{SHA}_this_will_be_in_the_migration_filename.py` .
2018-03-27 18:48:57 -04:00
2019-12-18 12:59:42 -05:00
[Example commit ](https://github.com/apache/incubator-superset/commit/d3e83b0fd572c9d6c1297543d415a332858e262 )
2018-03-27 18:48:57 -04:00
2018-09-19 13:01:51 -04:00
1. Upgrade the DB
2018-04-06 19:14:14 -04:00
2019-12-18 12:59:42 -05:00
```bash
superset db upgrade
```
2018-03-27 18:48:57 -04:00
2019-12-18 12:59:42 -05:00
The output should look like this:
2018-03-27 18:48:57 -04:00
2019-12-18 12:59:42 -05:00
```
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 1a1d627ebd8e -> 40a0a483dd12, add_metadata_column_to_annotation_model.py
```
2018-03-27 18:48:57 -04:00
2018-09-19 13:01:51 -04:00
1. Add column to view
2018-03-27 18:48:57 -04:00
2019-12-18 12:59:42 -05:00
Since there is a new column, we need to add it to the AppBuilder Model view.
2018-07-23 12:43:09 -04:00
2019-12-18 12:59:42 -05:00
[Example commit ](https://github.com/apache/incubator-superset/pull/5745/commits/6220966e2a0a0cf3e6d87925491f8920fe8a3458 )
2018-07-23 12:43:09 -04:00
2019-11-05 02:13:21 -05:00
1. Test the migration's `down` method
2019-12-18 12:59:42 -05:00
```bash
superset db downgrade
```
2019-11-05 02:13:21 -05:00
2019-12-18 12:59:42 -05:00
The output should look like this:
2019-11-05 02:13:21 -05:00
2019-12-18 12:59:42 -05:00
```
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running downgrade 40a0a483dd12 -> 1a1d627ebd8e, add_metadata_column_to_annotation_model.py
```
2019-11-05 02:13:21 -05:00
2018-09-19 13:01:51 -04:00
### Merging DB migrations
2018-07-23 12:43:09 -04:00
2018-09-19 13:01:51 -04:00
When two DB migrations collide, you'll get an error message like this one:
2018-07-23 12:43:09 -04:00
```
2018-09-19 13:01:51 -04:00
alembic.util.exc.CommandError: Multiple head revisions are present for
given argument 'head'; please specify a specific target
revision, '< branchname > @head' to narrow to a specific head,
or 'heads' for all heads`
2018-07-23 12:43:09 -04:00
```
2018-09-19 13:01:51 -04:00
To fix it:
2018-09-12 13:16:58 -04:00
2018-09-19 13:01:51 -04:00
1. Get the migration heads
2018-09-12 13:16:58 -04:00
2019-12-18 12:59:42 -05:00
```bash
superset db heads
```
2018-09-12 13:16:58 -04:00
2019-12-18 12:59:42 -05:00
This should list two or more migration hashes.
2018-09-12 13:16:58 -04:00
2018-09-19 13:01:51 -04:00
1. Create a new merge migration
2018-09-12 13:16:58 -04:00
2019-12-18 12:59:42 -05:00
```bash
superset db merge {HASH1} {HASH2}
```
2018-09-12 13:16:58 -04:00
2018-09-19 13:01:51 -04:00
1. Upgrade the DB to the new checkpoint
2018-09-12 13:16:58 -04:00
2019-12-18 12:59:42 -05:00
```bash
superset db upgrade
```
2019-03-27 01:50:19 -04:00
### SQL Lab Async
It's possible to configure a local database to operate in `async` mode,
to work on `async` related features.
To do this, you'll need to:
2019-12-18 12:59:42 -05:00
- Add an additional database entry. We recommend you copy the connection
2019-06-25 16:34:48 -04:00
string from the database labeled `main` , and then enable `SQL Lab` and the
2019-03-27 01:50:19 -04:00
features you want to use. Don't forget to check the `Async` box
2019-12-18 12:59:42 -05:00
- Configure a results backend, here's a local `FileSystemCache` example,
2019-03-27 01:50:19 -04:00
not recommended for production,
but perfect for testing (stores cache in `/tmp` )
2020-03-26 19:55:22 -04:00
2019-12-18 12:59:42 -05:00
```python
from werkzeug.contrib.cache import FileSystemCache
RESULTS_BACKEND = FileSystemCache('/tmp/sqllab')
```
2020-03-26 19:55:22 -04:00
- Start up a celery worker
2019-12-18 12:59:42 -05:00
```shell script
celery worker --app=superset.tasks.celery_app:app -Ofair
```
2019-03-27 01:50:19 -04:00
Note that:
2019-12-18 12:59:42 -05:00
- for changes that affect the worker logic, you'll have to
2019-03-27 01:50:19 -04:00
restart the `celery worker` process for the changes to be reflected.
2019-12-18 12:59:42 -05:00
- The message queue used is a `sqlite` database using the `SQLAlchemy`
2019-03-27 01:50:19 -04:00
experimental broker. Ok for testing, but not recommended in production
2019-12-18 12:59:42 -05:00
- In some cases, you may want to create a context that is more aligned
2019-03-27 01:50:19 -04:00
to your production environment, and use the similar broker as well as
results backend configuration
2019-12-18 12:59:42 -05:00
2019-11-08 17:19:22 -05:00
## Chart Parameters
Chart parameters are stored as a JSON encoded string the `slices.params` column and are often referenced throughout the code as form-data. Currently the form-data is neither versioned nor typed as thus is somewhat free-formed. Note in the future there may be merit in using something like [JSON Schema ](https://json-schema.org/ ) to both annotate and validate the JSON object in addition to using a Mypy `TypedDict` (introduced in Python 3.8) for typing the form-data in the backend. This section serves as a potential primer for that work.
The following tables provide a non-exhausive list of the various fields which can be present in the JSON object grouped by the Explorer pane sections. These values were obtained by extracting the distinct fields from a legacy deployment consisting of tens of thousands of charts and thus some fields may be missing whilst others may be deprecated.
Note not all fields are correctly catagorized. The fields vary based on visualization type and may apprear in different sections depending on the type. Verified deprecated columns may indicate a missing migration and/or prior migrations which were unsucessful and thus future work may be required to clean up the form-data.
### Datasource & Chart Type
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| ----------------- | -------- | ----------------------------------- |
| `database_name` | _string_ | _Deprecated?_ |
| `datasource` | _string_ | `<datasouce_id>__<datasource_type>` |
| `datasource_id` | _string_ | _Deprecated?_ See `datasource` |
| `datasource_name` | _string_ | _Deprecated?_ |
| `datasource_type` | _string_ | _Deprecated?_ See `datasource` |
| `viz_type` | _string_ | The **Visualization Type** widget |
2019-11-08 17:19:22 -05:00
### Time
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| ---------------------- | --------------- | ------------------------------------- |
| `date_filter` | _N/A_ | _Deprecated?_ |
| `date_time_format` | _N/A_ | _Deprecated?_ |
| `druid_time_origin` | _string_ | The Druid **Origin** widget |
| `granularity` | _string_ | The Druid **Time Granularity** widget |
| `granularity_sqla` | _string_ | The SQLA **Time Column** widget |
| `time_grain_sqla` | _string_ | The SQLA **Time Grain** widget |
| `time_range` | _string_ | The **Time range** widget |
| `time_range_endpoints` | _array(string)_ | Used by SIP-15 [HIDDEN] |
2019-11-08 17:19:22 -05:00
### GROUP BY
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| ------------------------- | --------------- | --------------------------- |
| `metrics` | _array(string)_ | See Query section |
2019-11-08 17:19:22 -05:00
| `order_asc` | - | See Query section |
| `row_limit` | - | See Query section |
| `timeseries_limit_metric` | - | See Query section |
### NOT GROUPED BY
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| --------------- | --------------- | ----------------------- |
| `all_columns` | _array(string)_ | The **Columns** widget |
| `order_by_cols` | _array(string)_ | The **Ordering** widget |
2019-11-08 17:19:22 -05:00
| `row_limit` | - | See Query section |
### Y Axis 1
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| --------------- | ---- | -------------------------------------------------- |
2019-11-08 17:19:22 -05:00
| `metric` | - | The **Left Axis Metric** widget. See Query section |
| `y_axis_format` | - | See Y Axis section |
### Y Axis 2
2019-12-18 12:59:42 -05:00
| Field | Type | Notes |
| ----------------- | -------- | --------------------------------------------------- |
| `metric_2` | - | The **Right Axis Metric** widget. See Query section |
| `y_axis_2_format` | _string_ | The **Right Axis Format** widget |
2019-11-08 17:19:22 -05:00
### Query
2019-12-18 12:59:42 -05:00
| Field | Type | Notes |
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------- | ------------------------------------------------- |
| `adhoc_filters` | _array(object)_ | The **Filters** widget |
| `all_columns_x` | _array(string)_ | The **Numeric Columns** widget |
| `columns` | _array(string)_ | The **Breakdowns** widget |
| `contribution` | _boolean_ | The **Contribution** widget |
| `groupby` | _array(string)_ | The **Group by** or **Series** widget |
| `limit` | _number_ | The **Series Limit** widget |
| `max_bubble_size` | _number_ | The **Max Bubble Size** widget |
| `metric` < br > `metric_2`< br > `metrics`< br > `percent_mertics`< br > `secondary_metric`< br > `size`< br > `x`< br > `y` | _string_ ,_object_,_array(string)_,_array(object)_ | The metric(s) depending on the visualization type |
| `order_asc` | _boolean_ | The **Sort Descending** widget |
| `row_limit` | _number_ | The **Row limit** widget |
| `timeseries_limit_metric` | _object_ | The **Sort By** widget |
2020-02-24 17:31:23 -05:00
The `metric` (or equivalent) and `timeseries_limit_metric` fields are all composed of either metric names or the JSON representation of the `AdhocMetric` TypeScript type. The `adhoc_filters` is composed of the JSON represent of the `AdhocFilter` TypeScript type (which can comprise of columns or metrics depending on whether it is a WHERE or HAVING clause). The `all_columns` , `all_columns_x` , `columns` , `groupby` , and `order_by_cols` fields all represent column names.
2019-11-08 17:19:22 -05:00
2019-11-20 14:01:14 -05:00
### Filters Configuration
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| ---------------- | ------------- | --------------------------------- |
2019-11-20 14:01:14 -05:00
| `filter_configs` | array(object) | The filter-box **Filters** widget |
2019-12-18 12:59:42 -05:00
The filter-box configuration references column names (via the `column` key) and optionally metric names (via the `metric` key) if sorting is defined.
2019-11-20 14:01:14 -05:00
2019-11-08 17:19:22 -05:00
### Options
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| ---------------------- | --------- | ------------------------------------ |
| `compare_lag` | _number_ | The **Comparison Period Lag** widget |
| `compare_suffix` | _string_ | The **Comparison suffix** widget |
| `show_trend_line` | _boolean_ | The **Show Trend Line** widget |
| `start_y_axis_at_zero` | _boolean_ | The **Start y-axis at 0** widget |
2019-11-08 17:19:22 -05:00
### Chart Options
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| --------------------- | --------- | ------------------------------------------------ |
| `color_picker` | _object_ | The **Fixed Color** widget |
| `donut` | _boolean_ | The **Donut** widget |
| `global_opacity` | _number_ | The **Opacity** widget |
| `header_font_size` | _number_ | The **Big Number Font Size** widget (or similar) |
| `label_colors` | _object_ | The **Color Scheme** widget |
| `labels_outside` | _boolean_ | The **Put labels outside** widget |
| `line_interpolation` | _string_ | The **Line Style** widget |
| `link_length` | _number_ | The **No of Bins** widget |
| `normalized` | _boolean_ | The **Normalized** widget |
| `number_format` | _string_ | The **Number format** widget |
| `pie_label_type` | _string_ | [HIDDEN] |
| `rich_tooltip` | _boolean_ | The **Rich Tooltip** widget |
| `send_time_range` | _boolean_ | The **Show Markers** widget |
| `show_brush` | _string_ | The **Show Range Filter** widget |
| `show_legend` | _boolean_ | The **Legend** widget |
| `show_markers` | _string_ | The **Show Markers** widget |
| `subheader_font_size` | _number_ | The **Subheader Font Size** widget |
2019-11-08 17:19:22 -05:00
### X Axis
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| -------------------- | --------- | ---------------------------- |
| `bottom_margin` | _string_ | The **Bottom Margin** widget |
| `x_axis_format` | _string_ | The **X Axis Format** widget |
| `x_axis_label` | _string_ | The **X Axis Label** widget |
| `x_axis_showminmax` | _boolean_ | The **X bounds** widget |
| `x_log_scale` | _N/A_ | _Deprecated?_ |
| `x_ticks_layout` | _string_ | The **X Tick Layout** widget |
2019-11-08 17:19:22 -05:00
### Y Axis
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| ------------------- | --------------- | ---------------------------- |
| `left_margin` | _number_ | The **Left Margin** widget |
| `y_axis_2_label` | _N/A_ | _Deprecated?_ |
| `y_axis_bounds` | _array(string)_ | The **Y Axis Bounds** widget |
| `y_axis_format` | _string_ | The **Y Axis Format** widget |
| `y_axis_label` | _string_ | The **Y Axis Label** widget |
| `y_axis_showminmax` | _boolean_ | The **Y bounds** widget |
| `y_axis_zero` | _N/A_ | _Deprecated?_ |
| `y_log_scale` | _boolean_ | The **Y Log Scale** widget |
2019-11-08 17:19:22 -05:00
Note the `y_axis_format` is defined under various section for some charts.
### Other
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| -------------- | -------- | ------------ |
| `color_scheme` | _string_ | |
| `slice_id` | _number_ | The slice ID |
| `url_params` | _object_ | |
2019-11-08 17:19:22 -05:00
### Unclassified
| Field | Type | Notes |
2019-12-18 12:59:42 -05:00
| ------------------------------- | ----- | ----- |
| `add_to_dash` | _N/A_ | |
| `all_columns_y` | _N/A_ | |
| `annotation_layers` | _N/A_ | |
| `autozoom` | _N/A_ | |
| `bar_stacked` | _N/A_ | |
| `cache_timeout` | _N/A_ | |
| `code` | _N/A_ | |
| `collapsed_fieldsets` | _N/A_ | |
| `column_collection` | _N/A_ | |
| `comparison type` | _N/A_ | |
| `contribution` | _N/A_ | |
| `country_fieldtype` | _N/A_ | |
| `date_filter` | _N/A_ | |
| `deck_slices` | _N/A_ | |
| `default_filters` | _N/A_ | |
| `dimension` | _N/A_ | |
| `end_spatial` | _N/A_ | |
| `entity` | _N/A_ | |
| `expanded_slices` | _N/A_ | |
| `extra_filters` | _N/A_ | |
| `extruded` | _N/A_ | |
| `fill_color_picker` | _N/A_ | |
| `filled` | _N/A_ | |
| `filter_immune_slice_fields` | _N/A_ | |
| `filter_immune_slices` | _N/A_ | |
| `filter_nulls` | _N/A_ | |
| `flt_col_0` | _N/A_ | |
| `flt_col_1` | _N/A_ | |
| `flt_eq_0` | _N/A_ | |
| `flt_eq_1` | _N/A_ | |
| `flt_op_0` | _N/A_ | |
| `flt_op_1` | _N/A_ | |
| `goto_dash` | _N/A_ | |
| `grid_size` | _N/A_ | |
| `import_time` | _N/A_ | |
| `instant_filtering` | _N/A_ | |
| `js_agg_function` | _N/A_ | |
| `js_columns` | _N/A_ | |
| `label` | _N/A_ | |
| `labels_outside` | _N/A_ | |
| `legend_position` | _N/A_ | |
| `line_charts` | _N/A_ | |
| `line_charts_2` | _N/A_ | |
| `line_column` | _N/A_ | |
| `line_type` | _N/A_ | |
| `line_width` | _N/A_ | |
| `linear_color_scheme` | _N/A_ | |
| `log_scale` | _N/A_ | |
| `mapbox_label` | _N/A_ | |
| `mapbox_style` | _N/A_ | |
| `marker_labels` | _N/A_ | |
| `marker_line_labels` | _N/A_ | |
| `marker_lines` | _N/A_ | |
| `markers` | _N/A_ | |
| `markup_type` | _N/A_ | |
| `max_radius` | _N/A_ | |
| `min_periods` | _N/A_ | |
| `min_radius` | _N/A_ | |
| `multiplier` | _N/A_ | |
| `new_dashboard_name` | _N/A_ | |
| `new_slice_name` | _N/A_ | |
| `normalize_across` | _N/A_ | |
| `num_buckets` | _N/A_ | |
| `num_period_compare` | _N/A_ | |
| `order_bars` | _N/A_ | |
| `order_desc` | _N/A_ | |
| `pandas_aggfunc` | _N/A_ | |
| `period_ratio_type` | _N/A_ | |
| `perm` | _N/A_ | |
| `point_radius_fixed` | _N/A_ | |
| `point_unit` | _N/A_ | |
| `prefix_metric_with_slice_name` | _N/A_ | |
| `range_labels` | _N/A_ | |
| `ranges` | _N/A_ | |
| `rdo_save` | _N/A_ | |
| `reduce_x_ticks` | _N/A_ | |
| `refresh_frequency` | _N/A_ | |
| `remote_id` | _N/A_ | |
| `resample_fillmethod` | _N/A_ | |
| `resample_how` | _N/A_ | |
| `resample_method` | _N/A_ | |
| `resample_rule` | _N/A_ | |
| `reverse_long_lat` | _N/A_ | |
| `rolling_periods` | _N/A_ | |
| `rolling_type` | _N/A_ | |
| `rose_area_proportion` | _N/A_ | |
| `save_to_dashboard_id` | _N/A_ | |
| `schema` | _N/A_ | |
| `select_country` | _N/A_ | |
| `series` | _N/A_ | |
| `show_bar_value` | _N/A_ | |
| `show_brush` | _N/A_ | |
| `show_bubbles` | _N/A_ | |
| `show_controls` | _N/A_ | |
| `show_druid_time_granularity` | _N/A_ | |
| `show_druid_time_origin` | _N/A_ | |
| `show_labels` | _N/A_ | |
| `show_sqla_time_column` | _N/A_ | |
| `show_sqla_time_granularity` | _N/A_ | |
| `show_values` | _N/A_ | |
| `slice_name` | _N/A_ | |
| `spatial` | _N/A_ | |
| `stacked_style` | _N/A_ | |
| `start_spatial` | _N/A_ | |
| `stroke_color_picker` | _N/A_ | |
| `stroke_width` | _N/A_ | |
| `stroked` | _N/A_ | |
| `subheader` | _N/A_ | |
| `table_filter` | _N/A_ | |
| `time_compare` | _N/A_ | |
| `timed_refresh_immune_slices` | _N/A_ | |
| `toggle_polygons` | _N/A_ | |
| `url` | _N/A_ | |
| `userid` | _N/A_ | |
| `viewport` | _N/A_ | |
| `viewport_zoom` | _N/A_ | |