Compare commits

...

29 Commits

Author SHA1 Message Date
Matheus Batista 5a6b3858d2
Merge 35c7b219e5 into f5843fe588 2024-05-05 02:12:30 -03:00
Maxime Beauchemin f5843fe588
fix: database logos look stretched (#28340) 2024-05-03 17:23:42 -07:00
Maxime Beauchemin 49231da42f
docs: various improvements across the docs (#28285) 2024-05-03 15:27:40 -07:00
Frank Zimper 517f254726
fix(website): links corrected (#28333) 2024-05-03 10:18:05 -07:00
Matheus Batista 35c7b219e5 Add tests for createMultiFormatter 2024-04-03 12:27:52 -03:00
Matheus Batista f3bf4b521a Fix linting errors 2024-03-28 18:20:25 -03:00
Matheus Batista 595ec2457e Merge remote-tracking branch 'origin' into add-time-translation 2024-03-28 16:46:59 -03:00
Matheus Batista cbc8f2a332
Merge branch 'master' into add-time-translation 2023-11-08 16:50:48 -03:00
Matheus Batista 51ad64fd3b Merge remote-tracking branch 'origin' into add-time-translation 2023-10-22 16:56:53 -03:00
Matheus Batista 38b4890d42 Remove merge error 2023-07-11 13:22:08 -03:00
Matheus Batista accabf15f5 Merge remote-tracking branch 'origin/master' into add-time-translation 2023-07-05 14:23:49 -03:00
Matheus Batista b9428481fe Fix linter 2023-06-14 16:39:27 -03:00
Matheus Batista 07605e4513 Remove unused code and add tests for time registry 2023-06-14 16:39:27 -03:00
Matheus Batista 1b01a46d93 Fix nvd3 utils tests 2023-06-14 16:39:27 -03:00
Matheus Batista 4298700b1d Fix time format index test 2023-06-14 16:39:27 -03:00
Matheus Batista 06d0dcc6dc Update tests for smart date formatters 2023-06-14 16:39:27 -03:00
Matheus Batista 4884d71a4e Add d3-time-format to package 2023-06-14 16:39:27 -03:00
Matheus Batista 0343e59425 Add D3_TIME_FORMAT to config 2023-06-14 16:39:27 -03:00
Matheus Batista 63cb0a7896 Add d3_time_format to base views 2023-06-14 16:39:27 -03:00
Matheus Batista e25b615ed0 Load d3_time_format into setupFormatter 2023-06-14 16:39:27 -03:00
Matheus Batista 308dd6297b Add d3_time_format to bootstrap data 2023-06-14 16:39:27 -03:00
Matheus Batista 94c50c3f99 Use registry to retrieve smart date formatters 2023-06-14 16:39:25 -03:00
Matheus Batista 807f370bad Change setup formatters to load smart formatters into the registry 2023-06-14 16:38:53 -03:00
Matheus Batista fa0f0cdb32 Fix smart detailed id 2023-06-14 16:38:53 -03:00
Matheus Batista e592a3ffea Change smart formatters 2023-06-14 16:38:53 -03:00
Matheus Batista c3083ea3ca Pass locale attribute to smart formatters 2023-06-14 16:38:53 -03:00
Matheus Batista febd85e268 Add support to locale on time format registry 2023-06-14 16:38:53 -03:00
Matheus Batista 23a7515815 Add support for locale on createMultiFormatter 2023-06-14 16:38:53 -03:00
Matheus Batista 5b9acd5b81 Add default config for time format 2023-06-14 16:38:53 -03:00
90 changed files with 4775 additions and 3968 deletions

View File

@ -4,6 +4,7 @@ on:
push:
paths:
- "docs/**"
- "README.md"
branches:
- "master"

View File

@ -47,7 +47,7 @@ repos:
hooks:
- id: check-docstring-first
- id: check-added-large-files
exclude: \.(geojson)$
exclude: ^.*\.(geojson)$|^docs/static/img/screenshots/.*
- id: check-yaml
exclude: ^helm/superset/templates/
- id: debug-statements

View File

@ -64,6 +64,7 @@ temporary_superset_ui/*
# docs overrides for third party logos we don't have the rights to
google-big-query.svg
google-sheets.svg
ibm-db2.svg
postgresql.svg
snowflake.svg

View File

@ -20,5 +20,5 @@ Contributions are welcome and are greatly appreciated! Every
little bit helps, and credit will always be given.
All matters related to contributions have moved to [this section of
the official Superset documentation](https://superset.apache.org/docs/contributing/contributing/). Source for the documentation is
the official Superset documentation](https://superset.apache.org/docs/contributing/). Source for the documentation is
[located here](https://github.com/apache/superset/tree/master/docs/docs).

100
README.md
View File

@ -1,3 +1,7 @@
---
hide_title: true
sidebar_position: 1
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@ -30,12 +34,14 @@ under the License.
<picture width="500">
<source
width="600"
media="(prefers-color-scheme: dark)"
src="https://github.com/apache/superset/raw/master/superset-frontend/src/assets/branding/superset-logo-horiz-apache-dark.png"
src="https://superset.apache.org/img/superset-logo-horiz-dark.svg"
alt="Superset logo (dark)"
/>
<img
src="https://github.com/apache/superset/raw/master/superset-frontend/src/assets/branding/superset-logo-horiz-apache.png"
width="600"
src="https://superset.apache.org/img/superset-logo-horiz-apache.svg"
alt="Superset logo (light)"
/>
</picture>
@ -45,11 +51,11 @@ A modern, enterprise-ready business intelligence web application.
[**Why Superset?**](#why-superset) |
[**Supported Databases**](#supported-databases) |
[**Installation and Configuration**](#installation-and-configuration) |
[**Release Notes**](RELEASING/README.md#release-notes-for-recent-releases) |
[**Release Notes**](https://github.com/apache/superset/blob/master/RELEASING/README.md#release-notes-for-recent-releases) |
[**Get Involved**](#get-involved) |
[**Contributor Guide**](#contributor-guide) |
[**Resources**](#resources) |
[**Organizations Using Superset**](RESOURCES/INTHEWILD.md)
[**Organizations Using Superset**](https://github.com/apache/superset/blob/master/RESOURCES/INTHEWILD.md)
## Why Superset?
@ -77,19 +83,19 @@ https://superset.staged.apache.org/superset-video-4k.mp4
**Large Gallery of Visualizations**
<kbd><img title="Gallery" src="superset-frontend/src/assets/images/screenshots/gallery.jpg"/></kbd><br/>
<kbd><img title="Gallery" src="https://superset.apache.org/img/screenshots/gallery.jpg"/></kbd><br/>
**Craft Beautiful, Dynamic Dashboards**
<kbd><img title="View Dashboards" src="superset-frontend/src/assets/images/screenshots/slack_dash.jpg"/></kbd><br/>
<kbd><img title="View Dashboards" src="https://superset.apache.org/img/screenshots/slack_dash.jpg"/></kbd><br/>
**No-Code Chart Builder**
<kbd><img title="Slice & dice your data" src="superset-frontend/src/assets/images/screenshots/explore.jpg"/></kbd><br/>
<kbd><img title="Slice & dice your data" src="https://superset.apache.org/img/screenshots/explore.jpg"/></kbd><br/>
**Powerful SQL Editor**
<kbd><img title="SQL Lab" src="superset-frontend/src/assets/images/screenshots/sql_lab.jpg"/></kbd><br/>
<kbd><img title="SQL Lab" src="https://superset.apache.org/img/screenshots/sql_lab.jpg"/></kbd><br/>
## Supported Databases
@ -98,39 +104,39 @@ Superset can query data from any SQL-speaking datastore or data engine (Presto,
Here are some of the major database solutions that are supported:
<p align="center">
<img src="superset-frontend/src/assets/images/redshift.png" alt="redshift" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/google-biquery.png" alt="google-biquery" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/snowflake.png" alt="snowflake" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/trino.png" alt="trino" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/presto.png" alt="presto" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/databricks.png" alt="databricks" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/druid.png" alt="druid" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/firebolt.png" alt="firebolt" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/timescale.png" alt="timescale" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/rockset.png" alt="rockset" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/postgresql.png" alt="postgresql" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/mysql.png" alt="mysql" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/mssql-server.png" alt="mssql-server" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/db2.png" alt="db2" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/sqlite.png" alt="sqlite" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/sybase.png" alt="sybase" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/mariadb.png" alt="mariadb" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/vertica.png" alt="vertica" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/oracle.png" alt="oracle" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/firebird.png" alt="firebird" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/greenplum.png" alt="greenplum" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/clickhouse.png" alt="clickhouse" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/exasol.png" alt="exasol" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/monet-db.png" alt="monet-db" border="0" width="200" height="80" />
<img src="superset-frontend/src/assets/images/apache-kylin.png" alt="apache-kylin" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/hologres.png" alt="hologres" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/netezza.png" alt="netezza" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/pinot.png" alt="pinot" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/teradata.png" alt="teradata" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/yugabyte.png" alt="yugabyte" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/databend.png" alt="databend" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/starrocks.png" alt="starrocks" border="0" width="200" height="80"/>
<img src="superset-frontend/src/assets/images/doris.png" alt="doris" border="0" width="200" height="80"/>
<img src="https://superset.apache.org/img/databases/redshift.png" alt="redshift" border="0" width="200"/>
<img src="https://superset.apache.org/img/databases/google-biquery.png" alt="google-biquery" border="0" width="200"/>
<img src="https://superset.apache.org/img/databases/snowflake.png" alt="snowflake" border="0" width="200"/>
<img src="https://superset.apache.org/img/databases/trino.png" alt="trino" border="0" width="150" />
<img src="https://superset.apache.org/img/databases/presto.png" alt="presto" border="0" width="200"/>
<img src="https://superset.apache.org/img/databases/databricks.png" alt="databricks" border="0" width="160" />
<img src="https://superset.apache.org/img/databases/druid.png" alt="druid" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/firebolt.png" alt="firebolt" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/timescale.png" alt="timescale" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/rockset.png" alt="rockset" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/postgresql.png" alt="postgresql" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/mysql.png" alt="mysql" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/mssql-server.png" alt="mssql-server" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/imb-db2.svg" alt="db2" border="0" width="220" />
<img src="https://superset.apache.org/img/databases/sqlite.png" alt="sqlite" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/sybase.png" alt="sybase" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/mariadb.png" alt="mariadb" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/vertica.png" alt="vertica" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/oracle.png" alt="oracle" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/firebird.png" alt="firebird" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/greenplum.png" alt="greenplum" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/clickhouse.png" alt="clickhouse" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/exasol.png" alt="exasol" border="0" width="160" />
<img src="https://superset.apache.org/img/databases/monet-db.png" alt="monet-db" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/apache-kylin.png" alt="apache-kylin" border="0" width="80"/>
<img src="https://superset.apache.org/img/databases/hologres.png" alt="hologres" border="0" width="80"/>
<img src="https://superset.apache.org/img/databases/netezza.png" alt="netezza" border="0" width="80"/>
<img src="https://superset.apache.org/img/databases/pinot.png" alt="pinot" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/teradata.png" alt="teradata" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/yugabyte.png" alt="yugabyte" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/databend.png" alt="databend" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/starrocks.png" alt="starrocks" border="0" width="200" />
<img src="https://superset.apache.org/img/databases/doris.png" alt="doris" border="0" width="200" />
</p>
**A more comprehensive list of supported databases** along with the configuration instructions can be found [here](https://superset.apache.org/docs/configuration/databases).
@ -159,9 +165,9 @@ how to set up a development environment.
## Resources
- [Superset "In the Wild"](RESOURCES/INTHEWILD.md) - open a PR to add your org to the list!
- [Feature Flags](RESOURCES/FEATURE_FLAGS.md) - the status of Superset's Feature Flags.
- [Standard Roles](RESOURCES/STANDARD_ROLES.md) - How RBAC permissions map to roles.
- [Superset "In the Wild"](https://github.com/apache/superset/blob/master/RESOURCES/INTHEWILD.md) - open a PR to add your org to the list!
- [Feature Flags](https://github.com/apache/superset/blob/master/RESOURCES/FEATURE_FLAGS.md) - the status of Superset's Feature Flags.
- [Standard Roles](https://github.com/apache/superset/blob/master/RESOURCES/STANDARD_ROLES.md) - How RBAC permissions map to roles.
- [Superset Wiki](https://github.com/apache/superset/wiki) - Tons of additional community resources: best practices, community content and other information.
- [Superset SIPs](https://github.com/orgs/apache/projects/170) - The status of Superset's SIPs (Superset Improvement Proposals) for both consensus and implementation status.
@ -198,10 +204,10 @@ Understanding the Superset Points of View
- [Superset API](https://superset.apache.org/docs/rest-api)
## Repo Activity
<a href="https://next.ossinsight.io/widgets/official/compose-last-28-days-stats?repo_id=39464018" target="_blank" style="display: block" align="center">
<a href="https://next.ossinsight.io/widgets/official/compose-last-28-days-stats?repo_id=39464018" target="_blank" align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-last-28-days-stats/thumbnail.png?repo_id=39464018&image_size=auto&color_scheme=dark" width="655" height="auto">
<img alt="Performance Stats of apache/superset - Last 28 days" src="https://next.ossinsight.io/widgets/official/compose-last-28-days-stats/thumbnail.png?repo_id=39464018&image_size=auto&color_scheme=light" width="655" height="auto">
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-last-28-days-stats/thumbnail.png?repo_id=39464018&image_size=auto&color_scheme=dark" width="655" height="auto" />
<img alt="Performance Stats of apache/superset - Last 28 days" src="https://next.ossinsight.io/widgets/official/compose-last-28-days-stats/thumbnail.png?repo_id=39464018&image_size=auto&color_scheme=light" width="655" height="auto" />
</picture>
</a>

BIN
databases/trino.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

3
docs/.gitignore vendored
View File

@ -20,3 +20,6 @@ yarn-debug.log*
yarn-error.log*
docs/.zshrc
# Gets copied from the root of the project at build time (yarn start / yarn build)
docs/intro.md

View File

@ -5,7 +5,7 @@ sidebar_position: 2
version: 2
---
## Alerts and Reports
# Alerts and Reports
Users can configure automated alerts and reports to send dashboards or charts to an email recipient or Slack channel.
@ -14,11 +14,11 @@ Users can configure automated alerts and reports to send dashboards or charts to
Alerts and reports are disabled by default. To turn them on, you need to do some setup, described here.
### Requirements
## Requirements
#### Commons
### Commons
##### In your `superset_config.py` or `superset_config_docker.py`
#### In your `superset_config.py` or `superset_config_docker.py`
- `"ALERT_REPORTS"` [feature flag](/docs/configuration/configuring-superset#feature-flags) must be turned to True.
- `beat_schedule` in CeleryConfig must contain schedule for `reports.scheduler`.
@ -26,11 +26,11 @@ Alerts and reports are disabled by default. To turn them on, you need to do some
- emails: `SMTP_*` settings
- Slack messages: `SLACK_API_TOKEN`
###### Disable dry-run mode
##### Disable dry-run mode
Screenshots will be taken but no messages actually sent as long as `ALERT_REPORTS_NOTIFICATION_DRY_RUN = True`, its default value in `docker/pythonpath_dev/superset_config.py`. To disable dry-run mode and start receiving email/Slack notifications, set `ALERT_REPORTS_NOTIFICATION_DRY_RUN` to `False` in [superset config](https://github.com/apache/superset/blob/master/docker/pythonpath_dev/superset_config.py).
##### In your `Dockerfile`
#### In your `Dockerfile`
- You must install a headless browser, for taking screenshots of the charts and dashboards. Only Firefox and Chrome are currently supported.
> If you choose Chrome, you must also change the value of `WEBDRIVER_TYPE` to `"chrome"` in your `superset_config.py`.
@ -43,7 +43,7 @@ You can either install and configure the headless browser - see "Custom Dockerfi
*Note*: In this context, a "dev image" is the same application software as its corresponding non-dev image, just bundled with additional tools. So an image like `3.1.0-dev` is identical to `3.1.0` when it comes to stability, functionality, and running in production. The actual "in-development" versions of Superset - cutting-edge and unstable - are not tagged with version numbers on Docker Hub and will display version `0.0.0-dev` within the Superset UI.
#### Slack integration
### Slack integration
To send alerts and reports to Slack channels, you need to create a new Slack Application on your workspace.
@ -61,14 +61,14 @@ To send alerts and reports to Slack channels, you need to create a new Slack App
Note: when you configure an alert or a report, the Slack channel list takes channel names without the leading '#' e.g. use `alerts` instead of `#alerts`.
#### Kubernetes-specific
### Kubernetes-specific
- You must have a `celery beat` pod running. If you're using the chart included in the GitHub repository under [helm/superset](https://github.com/apache/superset/tree/master/helm/superset), you need to put `supersetCeleryBeat.enabled = true` in your values override.
- You can see the dedicated docs about [Kubernetes installation](/docs/installation/kubernetes) for more details.
#### Docker Compose specific
### Docker Compose specific
##### You must have in your `docker-compose.yml`
#### You must have in your `docker-compose.yml`
- A Redis message broker
- PostgreSQL DB instead of SQLlite
@ -195,14 +195,14 @@ Please refer to `ExecutorType` in the codebase for other executor types.
its default value of `http://0.0.0.0:8080/`.
### Custom Dockerfile
## Custom Dockerfile
If you're running the dev version of a released Superset image, like `apache/superset:3.1.0-dev`, you should be set with the above.
But if you're building your own image, or starting with a non-dev version, a webdriver (and headless browser) is needed to capture screenshots of the charts and dashboards which are then sent to the recipient.
Here's how you can modify your Dockerfile to take the screenshots either with Firefox or Chrome.
#### Using Firefox
### Using Firefox
```docker
FROM apache/superset:3.1.0
@ -223,7 +223,7 @@ RUN pip install --no-cache gevent psycopg2 redis
USER superset
```
#### Using Chrome
### Using Chrome
```docker
FROM apache/superset:3.1.0
@ -248,21 +248,21 @@ USER superset
Don't forget to set `WEBDRIVER_TYPE` and `WEBDRIVER_OPTION_ARGS` in your config if you use Chrome.
### Troubleshooting
## Troubleshooting
There are many reasons that reports might not be working. Try these steps to check for specific issues.
#### Confirm feature flag is enabled and you have sufficient permissions
### Confirm feature flag is enabled and you have sufficient permissions
If you don't see "Alerts & Reports" under the *Manage* section of the Settings dropdown in the Superset UI, you need to enable the `ALERT_REPORTS` feature flag (see above). Enable another feature flag and check to see that it took effect, to verify that your config file is getting loaded.
Log in as an admin user to ensure you have adequate permissions.
#### Check the logs of your Celery worker
### Check the logs of your Celery worker
This is the best source of information about the problem. In a docker compose deployment, you can do this with a command like `docker logs superset_worker --since 1h`.
#### Check web browser and webdriver installation
### Check web browser and webdriver installation
To take a screenshot, the worker visits the dashboard or chart using a headless browser, then takes a screenshot. If you are able to send a chart as CSV or text but can't send as PNG, your problem may lie with the browser.
@ -270,7 +270,7 @@ Superset docker images that have a tag ending with `-dev` have the Firefox headl
If you are handling the installation of that software on your own, or wish to use Chromium instead, do your own verification to ensure that the headless browser opens successfully in the worker environment.
#### Send a test email
### Send a test email
One symptom of an invalid connection to an email server is receiving an error of `[Errno 110] Connection timed out` in your logs when the report tries to send.
@ -301,7 +301,7 @@ Possible fixes:
- Some cloud hosts disable outgoing unauthenticated SMTP email to prevent spam. For instance, [Azure blocks port 25 by default on some machines](https://learn.microsoft.com/en-us/azure/virtual-network/troubleshoot-outbound-smtp-connectivity). Enable that port or use another sending method.
- Use another set of SMTP credentials that you verify works in this setup.
#### Browse to your report from the worker
### Browse to your report from the worker
The worker may be unable to reach the report. It will use the value of `WEBDRIVER_BASEURL` to browse to the report. If that route is invalid, or presents an authentication challenge that the worker can't pass, the report screenshot will fail.
@ -309,7 +309,7 @@ Check this by attempting to `curl` the URL of a report that you see in the error
In a deployment with authentication measures enabled like HTTPS and Single Sign-On, it may make sense to have the worker navigate directly to the Superset application running in the same location, avoiding the need to sign in. For instance, you could use `WEBDRIVER_BASEURL="http://superset_app:8088"` for a docker compose deployment, and set `"force_https": False,` in your `TALISMAN_CONFIG`.
### Scheduling Queries as Reports
## Scheduling Queries as Reports
You can optionally allow your users to schedule queries directly in SQL Lab. This is done by adding
extra metadata to saved queries, which are then picked up by an external scheduled (like

View File

@ -5,9 +5,9 @@ sidebar_position: 4
version: 1
---
## Async Queries via Celery
# Async Queries via Celery
### Celery
## Celery
On large analytic databases, its common to run queries that execute for minutes or hours. To enable
support for long running queries that execute beyond the typical web requests timeout (30-60
@ -89,7 +89,7 @@ issues arise. Please clear your existing results cache store when upgrading an e
- SQL Lab will _only run your queries asynchronously if_ you enable **Asynchronous Query Execution**
in your database settings (Sources > Databases > Edit record).
### Celery Flower
## Celery Flower
Flower is a web based tool for monitoring the Celery cluster which you can install from pip:

View File

@ -5,7 +5,7 @@ sidebar_position: 3
version: 1
---
## Caching
# Caching
Superset uses [Flask-Caching](https://flask-caching.readthedocs.io/) for caching purposes.
Flask-Caching supports various caching backends, including Redis (recommended), Memcached,
@ -33,7 +33,7 @@ FILTER_STATE_CACHE_CONFIG = {
}
```
### Dependencies
## Dependencies
In order to use dedicated cache stores, additional python libraries must be installed
@ -43,7 +43,7 @@ In order to use dedicated cache stores, additional python libraries must be inst
These libraries can be installed using pip.
### Fallback Metastore Cache
## Fallback Metastore Cache
Note, that some form of Filter State and Explore caching are required. If either of these caches
are undefined, Superset falls back to using a built-in cache that stores data in the metadata
@ -60,7 +60,7 @@ DATA_CACHE_CONFIG = {
}
```
### Chart Cache Timeout
## Chart Cache Timeout
The cache timeout for charts may be overridden by the settings for an individual chart, dataset, or
database. Each of these configurations will be checked in order before falling back to the default
@ -69,7 +69,7 @@ value defined in `DATA_CACHE_CONFIG`.
Note, that by setting the cache timeout to `-1`, caching for charting data can be disabled, either
per chart, dataset or database, or by default if set in `DATA_CACHE_CONFIG`.
### SQL Lab Query Results
## SQL Lab Query Results
Caching for SQL Lab query results is used when async queries are enabled and is configured using
`RESULTS_BACKEND`.
@ -79,7 +79,7 @@ instead requires a cachelib object.
See [Async Queries via Celery](/docs/configuration/async-queries-celery) for details.
### Caching Thumbnails
## Caching Thumbnails
This is an optional feature that can be turned on by activating its [feature flag](/docs/configuration/configuring-superset#feature-flags) on config:

View File

@ -5,28 +5,40 @@ sidebar_position: 1
version: 1
---
## Configuring Superset
# Configuring Superset
### Configuration
## superset_config.py
To configure your application, you need to create a file `superset_config.py`. Add this file to your
Superset exposes hundreds of configurable parameters through its
[config.py module](https://github.com/apache/superset/blob/master/superset/config.py). The
variables and objects exposed act as a public interface of the bulk of what you may want
to configure, alter and interface with. In this python module, you'll find all these
parameters, sensible defaults, as well as rich documentation in the form of comments
`PYTHONPATH` or create an environment variable `SUPERSET_CONFIG_PATH` specifying the full path of the `superset_config.py`.
To configure your application, you need to create you own configuration module, which
will allow you to override few or many of these parameters. Instead of altering the core module,
You'll want to define your own module (typically a file named `superset_config.py`.
Add this file to your `PYTHONPATH` or create an environment variable
`SUPERSET_CONFIG_PATH` specifying the full path of the `superset_config.py`.
For example, if deploying on Superset directly on a Linux-based system where your `superset_config.py` is under `/app` directory, you can run:
For example, if deploying on Superset directly on a Linux-based system where your
`superset_config.py` is under `/app` directory, you can run:
```bash
export SUPERSET_CONFIG_PATH=/app/superset_config.py
```
If you are using your own custom Dockerfile with official Superset image as base image, then you can add your overrides as shown below:
If you are using your own custom Dockerfile with official Superset image as base image,
then you can add your overrides as shown below:
```bash
COPY --chown=superset superset_config.py /app/
ENV SUPERSET_CONFIG_PATH /app/superset_config.py
```
Docker compose deployments handle application configuration differently. See [https://github.com/apache/superset/tree/master/docker#readme](https://github.com/apache/superset/tree/master/docker#readme) for details.
Docker compose deployments handle application configuration differently using specific conventions..
Refer to the [docker-compose tips & configuration](/docs/installation/docker-compose#docker-compose-tips--configuration)
for details.
The following is an example of just a few of the parameters you can set in your `superset_config.py` file:
@ -63,33 +75,39 @@ WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365
MAPBOX_API_KEY = ''
```
All the parameters and default values defined in
[https://github.com/apache/superset/blob/master/superset/config.py](https://github.com/apache/superset/blob/master/superset/config.py)
:::tip
Note that it is typical to copy and paste [only] the portions of the
core [superset/config.py](https://github.com/apache/superset/blob/master/superset/config.py) that
you want to alter, along with the related comments into your own `superset_config.py` file.
:::
All the parameters and default values defined
in [superset/config.py](https://github.com/apache/superset/blob/master/superset/config.py)
can be altered in your local `superset_config.py`. Administrators will want to read through the file
to understand what can be configured locally as well as the default values in place.
Since `superset_config.py` acts as a Flask configuration module, it can be used to alter the
settings Flask itself, as well as Flask extensions like `flask-wtf`, `flask-caching`, `flask-migrate`,
and `flask-appbuilder`. Flask App Builder, the web framework used by Superset, offers many
settings Flask itself, as well as Flask extensions that Superset bundles like
`flask-wtf`, `flask-caching`, `flask-migrate`,
and `flask-appbuilder`. Each one of these extensions offers intricate configurability.
Flask App Builder, the web framework used by Superset, also offers many
configuration settings. Please consult the
[Flask App Builder Documentation](https://flask-appbuilder.readthedocs.org/en/latest/config.html)
for more information on how to configure it.
Make sure to change:
You'll want to change:
- `SQLALCHEMY_DATABASE_URI`: by default it is stored at ~/.superset/superset.db
- `SECRET_KEY`: to a long random string
If you need to exempt endpoints from CSRF (e.g. if you are running a custom auth postback endpoint),
you can add the endpoints to `WTF_CSRF_EXEMPT_LIST`:
- `SQLALCHEMY_DATABASE_URI`: that by default points to sqlite database located at
~/.superset/superset.db
```
WTF_CSRF_EXEMPT_LIST = []
```
### Specifying a SECRET_KEY
## Specifying a SECRET_KEY
#### Adding an initial SECRET_KEY
### Adding an initial SECRET_KEY
Superset requires a user-specified SECRET_KEY to start up. This requirement was [added in version 2.1.0 to force secure configurations](https://preset.io/blog/superset-security-update-default-secret_key-vulnerability/). Add a strong SECRET_KEY to your `superset_config.py` file like:
@ -104,7 +122,7 @@ This key will be used for securely signing session cookies and encrypting sensit
Your deployment must use a complex, unique key.
:::
#### Rotating to a newer SECRET_KEY
### Rotating to a newer SECRET_KEY
If you wish to change your existing SECRET_KEY, add the existing SECRET_KEY to your `superset_config.py` file as
`PREVIOUS_SECRET_KEY = `and provide your new key as `SECRET_KEY =`. You can find your current SECRET_KEY with these
@ -117,9 +135,13 @@ from flask import current_app; print(current_app.config["SECRET_KEY"])
Save your `superset_config.py` with these values and then run `superset re-encrypt-secrets`.
### Using a production metastore
## Setting up a production metadata database
By default, Superset is configured to use SQLite, which is a simple and fast way to get started
Superset needs a database to store the information it manages, like the definitions of
charts, dashboards, and many other things.
By default, Superset is configured to use [SQLite](https://www.sqlite.org/),
a self-contained, single-file database that offers a simple and fast way to get started
(without requiring any installation). However, for production environments,
using SQLite is highly discouraged due to security, scalability, and data integrity reasons.
It's important to use only the supported database engines and consider using a different
@ -139,10 +161,17 @@ Use the following database drivers and connection strings:
| [PostgreSQL](https://www.postgresql.org/) | `pip install psycopg2` | `postgresql://<UserName>:<DBPassword>@<Database Host>/<Database Name>` |
| [MySQL](https://www.mysql.com/) | `pip install mysqlclient` | `mysql://<UserName>:<DBPassword>@<Database Host>/<Database Name>` |
:::tip
Properly setting up metadata store is beyond the scope of this documentation. We recommend
using a hosted managed service such as [Amazon RDS](https://aws.amazon.com/rds/) or
[Google Cloud Databases](https://cloud.google.com/products/databases?hl=en) to handle
service and supporting infrastructure and backup strategy.
:::
To configure Superset metastore set `SQLALCHEMY_DATABASE_URI` config key on `superset_config`
to the appropriate connection string.
### Running on a WSGI HTTP Server
## Running on a WSGI HTTP Server
While you can run Superset on NGINX or Apache, we recommend using Gunicorn in async mode. This
enables impressive concurrency even and is fairly easy to install and configure. Please refer to the
@ -171,12 +200,12 @@ If you're not using Gunicorn, you may want to disable the use of `flask-compress
Currently, Google BigQuery python sdk is not compatible with `gevent`, due to some dynamic monkeypatching on python core library by `gevent`.
So, when you use `BigQuery` datasource on Superset, you have to use `gunicorn` worker type except `gevent`.
### HTTPS Configuration
## HTTPS Configuration
You can configure HTTPS upstream via a load balancer or a reverse proxy (such as nginx) and do SSL/TLS Offloading before traffic reaches the Superset application. In this setup, local traffic from a Celery worker taking a snapshot of a chart for Alerts & Reports can access Superset at a `http://` URL, from behind the ingress point.
You can also configure [SSL in Gunicorn](https://docs.gunicorn.org/en/stable/settings.html#ssl) (the Python webserver) if you are using an official Superset Docker image.
### Configuration Behind a Load Balancer
## Configuration Behind a Load Balancer
If you are running superset behind a load balancer or reverse proxy (e.g. NGINX or ELB on AWS), you
may need to utilize a healthcheck endpoint so that your load balancer knows if your superset
@ -194,7 +223,7 @@ In case the reverse proxy is used for providing SSL encryption, an explicit defi
RequestHeader set X-Forwarded-Proto "https"
```
### Custom OAuth2 Configuration
## Custom OAuth2 Configuration
Superset is built on Flask-AppBuilder (FAB), which supports many providers out of the box
(GitHub, Twitter, LinkedIn, Google, Azure, etc). Beyond those, Superset can be configured to connect
@ -293,19 +322,19 @@ CUSTOM_SECURITY_MANAGER = CustomSsoSecurityManager
]
```
### LDAP Authentication
## LDAP Authentication
FAB supports authenticating user credentials against an LDAP server.
To use LDAP you must install the [python-ldap](https://www.python-ldap.org/en/latest/installing.html) package.
See [FAB's LDAP documentation](https://flask-appbuilder.readthedocs.io/en/latest/security.html#authentication-ldap)
for details.
### Mapping LDAP or OAUTH groups to Superset roles
## Mapping LDAP or OAUTH groups to Superset roles
AUTH_ROLES_MAPPING in Flask-AppBuilder is a dictionary that maps from LDAP/OAUTH group names to FAB roles.
It is used to assign roles to users who authenticate using LDAP or OAuth.
#### Mapping OAUTH groups to Superset roles
### Mapping OAUTH groups to Superset roles
The following `AUTH_ROLES_MAPPING` dictionary would map the OAUTH group "superset_users" to the Superset roles "Gamma" as well as "Alpha", and the OAUTH group "superset_admins" to the Superset role "Admin".
@ -315,7 +344,7 @@ AUTH_ROLES_MAPPING = {
"superset_admins": ["Admin"],
}
```
#### Mapping LDAP groups to Superset roles
### Mapping LDAP groups to Superset roles
The following `AUTH_ROLES_MAPPING` dictionary would map the LDAP DN "cn=superset_users,ou=groups,dc=example,dc=com" to the Superset roles "Gamma" as well as "Alpha", and the LDAP DN "cn=superset_admins,ou=groups,dc=example,dc=com" to the Superset role "Admin".
@ -327,11 +356,11 @@ AUTH_ROLES_MAPPING = {
```
Note: This requires `AUTH_LDAP_SEARCH` to be set. For more details, please see the [FAB Security documentation](https://flask-appbuilder.readthedocs.io/en/latest/security.html).
#### Syncing roles at login
### Syncing roles at login
You can also use the `AUTH_ROLES_SYNC_AT_LOGIN` configuration variable to control how often Flask-AppBuilder syncs the user's roles with the LDAP/OAUTH groups. If `AUTH_ROLES_SYNC_AT_LOGIN` is set to True, Flask-AppBuilder will sync the user's roles each time they log in. If `AUTH_ROLES_SYNC_AT_LOGIN` is set to False, Flask-AppBuilder will only sync the user's roles when they first register.
### Flask app Configuration Hook
## Flask app Configuration Hook
`FLASK_APP_MUTATOR` is a configuration function that can be provided in your environment, receives
the app object and can alter it in any way. For example, add `FLASK_APP_MUTATOR` into your
@ -354,7 +383,7 @@ def FLASK_APP_MUTATOR(app: Flask) -> None:
app.before_request_funcs.setdefault(None, []).append(make_session_permanent)
```
### Feature Flags
## Feature Flags
To support a diverse set of users, Superset has some features that are not enabled by default. For
example, some users have stronger security restrictions, while some others may not. So Superset

View File

@ -1,13 +1,12 @@
---
title: Country Map Tools
hide_title: true
sidebar_position: 10
version: 1
---
import countriesData from '../../data/countries.json';
## The Country Map Visualization
# The Country Map Visualization
The Country Map visualization allows you to plot lightweight choropleth maps of
your countries by province, states, or other subdivision types. It does not rely

View File

@ -1,18 +1,18 @@
---
title: Event Logging
hide_title: true
sidebar_position: 9
version: 1
---
## Logging
# Logging
### Event Logging
## Event Logging
Superset by default logs special action events in its internal database (DBEventLogger). These logs can be accessed
on the UI by navigating to **Security > Action Log**. You can freely customize these logs by
implementing your own event log class.
**When custom log class is enabled DBEventLogger is disabled and logs stop being populated in UI logs view.**
**When custom log class is enabled DBEventLogger is disabled and logs
stop being populated in UI logs view.**
To achieve both, custom log class should extend built-in DBEventLogger log class.
Here's an example of a simple JSON-to-stdout class:
@ -44,9 +44,10 @@ End by updating your config to pass in an instance of the logger you want to use
EVENT_LOGGER = JSONStdOutEventLogger()
```
### StatsD Logging
## StatsD Logging
Superset can be instrumented to log events to StatsD if desired. Most endpoints hit are logged as
Superset can be configured to log events to [StatsD](https://github.com/statsd/statsd)
if desired. Most endpoints hit are logged as
well as key events like query start and end in SQL Lab.
To setup StatsD logging, its a matter of configuring the logger in your `superset_config.py`.

View File

@ -5,7 +5,7 @@ sidebar_position: 11
version: 1
---
## Importing and Exporting Datasources
# Importing and Exporting Datasources
The superset cli allows you to import and export datasources from and to YAML. Datasources include
databases. The data is expected to be organized in the following hierarchy:
@ -26,7 +26,7 @@ databases. The data is expected to be organized in the following hierarchy:
| └── ... (more databases)
```
### Exporting Datasources to YAML
## Exporting Datasources to YAML
You can print your current datasources to stdout by running:
@ -61,7 +61,7 @@ superset export_datasource_schema
As a reminder, you can use the `-b` flag to include back references.
### Importing Datasources
## Importing Datasources
In order to import datasources from a ZIP file, run:
@ -75,9 +75,9 @@ The optional username flag **-u** sets the user used for the datasource import.
superset import_datasources -p <path / filename> -u 'admin'
```
### Legacy Importing Datasources
## Legacy Importing Datasources
#### From older versions of Superset to current version
### From older versions of Superset to current version
When using Superset version 4.x.x to import from an older version (2.x.x or 3.x.x) importing is supported as the command `legacy_import_datasources` and expects a JSON or directory of JSONs. The options are `-r` for recursive and `-u` for specifying a user. Example of legacy import without options:
@ -85,7 +85,7 @@ When using Superset version 4.x.x to import from an older version (2.x.x or 3.x.
superset legacy_import_datasources -p <path or filename>
```
#### From older versions of Superset to older versions
### From older versions of Superset to older versions
When using an older Superset version (2.x.x & 3.x.x) of Superset, the command is `import_datasources`. ZIP and YAML files are supported and to switch between them the feature flag `VERSIONED_EXPORT` is used. When `VERSIONED_EXPORT` is `True`, `import_datasources` expects a ZIP file, otherwise YAML. Example:

View File

@ -1,13 +1,12 @@
---
title: Additional Networking Settings
hide_title: true
title: Network and Security Settings
sidebar_position: 7
version: 1
---
## Additional Networking Settings
# Network and Security Settings
### CORS
## CORS
To configure CORS, or cross-origin resource sharing, the following dependency must be installed:
@ -21,7 +20,37 @@ The following keys in `superset_config.py` can be specified to configure CORS:
- `CORS_OPTIONS`: options passed to Flask-CORS
([documentation](https://flask-cors.corydolphin.com/en/latest/api.html#extension))
### Domain Sharding
## HTTP headers
Note that Superset bundles [flask-talisman](https://pypi.org/project/talisman/)
Self-descried as a small Flask extension that handles setting HTTP headers that can help
protect against a few common web application security issues.
## CSRF settings
Similarly, [flask-wtf](https://flask-wtf.readthedocs.io/en/0.15.x/config/) is used manage
some CSRF configurations. If you need to exempt endpoints from CSRF (e.g. if you are
running a custom auth postback endpoint), you can add the endpoints to `WTF_CSRF_EXEMPT_LIST`:
## SSH Tunneling
1. Turn on feature flag
- Change [`SSH_TUNNELING`](https://github.com/apache/superset/blob/eb8386e3f0647df6d1bbde8b42073850796cc16f/superset/config.py#L489) to `True`
- If you want to add more security when establishing the tunnel we allow users to overwrite the `SSHTunnelManager` class [here](https://github.com/apache/superset/blob/eb8386e3f0647df6d1bbde8b42073850796cc16f/superset/config.py#L507)
- You can also set the [`SSH_TUNNEL_LOCAL_BIND_ADDRESS`](https://github.com/apache/superset/blob/eb8386e3f0647df6d1bbde8b42073850796cc16f/superset/config.py#L508) this the host address where the tunnel will be accessible on your VPC
2. Create database w/ ssh tunnel enabled
- With the feature flag enabled you should now see ssh tunnel toggle.
- Click the toggle to enables ssh tunneling and add your credentials accordingly.
- Superset allows for 2 different type authentication (Basic + Private Key). These credentials should come from your service provider.
3. Verify data is flowing
- Once SSH tunneling has been enabled, go to SQL Lab and write a query to verify data is properly flowing.
## Domain Sharding
Chrome allows up to 6 open connections per domain at a time. When there are more than 6 slices in
dashboard, a lot of time fetch requests are queued up and wait for next available socket.
@ -42,7 +71,7 @@ or add the following setting in your `superset_config.py` file if domain shards
- `SESSION_COOKIE_DOMAIN = '.mydomain.com'`
### Middleware
## Middleware
Superset allows you to add your own middleware. To add your own middleware, update the
`ADDITIONAL_MIDDLEWARE` key in your `superset_config.py`. `ADDITIONAL_MIDDLEWARE` should be a list

View File

@ -4,18 +4,3 @@ hide_title: true
sidebar_position: 8
version: 1
---
## SSH Tunneling
1. Turn on feature flag
- Change [`SSH_TUNNELING`](https://github.com/apache/superset/blob/eb8386e3f0647df6d1bbde8b42073850796cc16f/superset/config.py#L489) to `True`
- If you want to add more security when establishing the tunnel we allow users to overwrite the `SSHTunnelManager` class [here](https://github.com/apache/superset/blob/eb8386e3f0647df6d1bbde8b42073850796cc16f/superset/config.py#L507)
- You can also set the [`SSH_TUNNEL_LOCAL_BIND_ADDRESS`](https://github.com/apache/superset/blob/eb8386e3f0647df6d1bbde8b42073850796cc16f/superset/config.py#L508) this the host address where the tunnel will be accessible on your VPC
2. Create database w/ ssh tunnel enabled
- With the feature flag enabled you should now see ssh tunnel toggle.
- Click the toggle to enables ssh tunneling and add your credentials accordingly.
- Superset allows for 2 different type authentication (Basic + Private Key). These credentials should come from your service provider.
3. Verify data is flowing
- Once SSH tunneling has been enabled, go to SQL Lab and write a query to verify data is properly flowing.

View File

@ -5,9 +5,9 @@ sidebar_position: 5
version: 1
---
## SQL Templating
# SQL Templating
### Jinja Templates
## Jinja Templates
SQL Lab and Explore supports [Jinja templating](https://jinja.palletsprojects.com/en/2.11.x/) in queries.
To enable templating, the `ENABLE_TEMPLATE_PROCESSING` [feature flag](/docs/configuration/configuring-superset#feature-flags) needs to be enabled in
@ -168,7 +168,7 @@ FEATURE_FLAGS = {
The available validators and names can be found in
[sql_validators](https://github.com/apache/superset/tree/master/superset/sql_validators).
### Available Macros
## Available Macros
In this section, we'll walkthrough the pre-defined Jinja macros in Superset.

View File

@ -5,7 +5,7 @@ sidebar_position: 6
version: 1
---
## Timezones
# Timezones
There are four distinct timezone components which relate to Apache Superset,

View File

@ -88,7 +88,7 @@ text strings from Superset's UI. You can jump into 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.
See [Translating](howtos#contribute-translations) for more details.
### Ask Questions

View File

@ -5,23 +5,29 @@ sidebar_position: 3
version: 1
---
## Using Docker Compose
import useBaseUrl from "@docusaurus/useBaseUrl";
**DO NOT USE THIS FOR PRODUCTION!**
# Using Docker Compose
The fastest way to try Superset locally is using Docker Compose on a Linux or Mac OSX
computer. Superset does not have official support for Windows. It's also the easiest
way to launch a fully functioning **development environment** quickly.
<img src={useBaseUrl("/img/docker-compose.webp" )} width="150" />
<br /><br />
:::caution
Since `docker-compose` is primarily designed to run a set of containers on **a single host**
and can't credibly support **high availability** as a result, we do not support nor recommend
and can't support requirements for **high availability**, we do not support nor recommend
using our `docker-compose` constructs to support production-type use-cases. For single host
environments, we recommend using [minikube](https://minikube.sigs.k8s.io/docs/start/) along
our [installing on k8s](https://superset.apache.org/docs/installation/running-on-kubernetes)
documentation.
:::
As mentioned in our [quickstart guidee](/docs/quickstart), The fastest way to try
Superset locally is using Docker Compose on a Linux or Mac OSX
computer. Superset does not have official support for Windows. It's also the easiest
way to launch a fully functioning **development environment** quickly.
Note that there are 3 major ways we support to run docker-compose:
1. **docker-compose.yml:** for interactive development, where we mount your local folder with the
frontend/backend files that you can edit and experience the changes you
@ -37,14 +43,14 @@ Note that there are 3 major ways we support to run docker-compose:
More on these two approaches after setting up the requirements for either.
### Requirements
## Requirements
Note that this documentation assumes that you have [Docker](https://www.docker.com),
[docker-compose](https://docs.docker.com/compose/), and
[git](https://git-scm.com/) installed.
### 1. Clone Superset's GitHub repository
## 1. Clone Superset's GitHub repository
[Clone Superset's repo](https://github.com/apache/superset) in your terminal with the
following command:
@ -56,7 +62,7 @@ git clone --depth=1 https://github.com/apache/superset.git
Once that command completes successfully, you should see a new `superset` folder in your
current directory.
### 2. Launch Superset Through Docker Compose
## 2. Launch Superset Through Docker Compose
First let's assume you're familiar with docker-compose mechanics. Here we'll refer generally
to `docker compose up` even though in some cases you may want to force a check for newer remote
@ -86,13 +92,13 @@ perform those operations. In this case, we recommend you set the env var
Simply trigger `npm i && npm run dev`, this should be MUCH faster.
:::
### Option #2 - build an immutable image from the local branch
### Option #2 - build a set of immutable images from the local branch
```bash
docker compose -f docker-compose-non-dev.yml up
```
### Option #3 - pull and build a release image from docker-hub
### Option #3 - boot up an official release
```bash
export TAG=3.1.1
@ -103,7 +109,7 @@ Here various release tags, github SHA, and latest `master` can be referenced by
Refer to the docker-related documentation to learn more about existing tags you can point to
from Docker Hub.
## General tips & configuration
## docker-compose tips & configuration
:::caution
All of the content belonging to a Superset instance - charts, dashboards, users, etc. - is stored in
@ -119,7 +125,7 @@ You should see a wall of logging output from the containers being launched on yo
this output slows, you should have a running instance of Superset on your local machine! To avoid
the wall of text on future runs, add the `-d` option to the end of the `docker compose up` command.
#### Configuring Further
### Configuring Further
The following is for users who want to configure how Superset runs in Docker Compose; otherwise, you
can skip to the next section.
@ -170,7 +176,7 @@ To disable the Scarf telemetry pixel, set the `SCARF_ANALYTICS` environment vari
your terminal and/or in your `docker/.env` file.
:::
### 3. Log in to Superset
## 3. Log in to Superset
Your local Superset instance also includes a Postgres server to store your data and is already
pre-loaded with some example datasets that ship with Superset. You can access Superset now via your
@ -187,7 +193,7 @@ username: admin
password: admin
```
### 4. Connecting Superset to your local database instance
## 4. Connecting Superset to your local database instance
When running Superset using `docker` or `docker compose` it runs in its own docker container, as if
the Superset was running in a separate machine entirely. Therefore attempts to connect to your local

View File

@ -5,12 +5,18 @@ sidebar_position: 1
version: 1
---
## Installing on Kubernetes
import useBaseUrl from "@docusaurus/useBaseUrl";
# Installing on Kubernetes
<img src={useBaseUrl("/img/k8s.png" )} width="150" />
<br /><br />
Running Superset on Kubernetes is supported with the provided [Helm](https://helm.sh/) chart
found in the official [Superset helm repository](https://apache.github.io/superset/index.yaml).
### Prerequisites
## Prerequisites
- A Kubernetes cluster
- Helm installed
@ -22,7 +28,7 @@ and works fantastically well with the Helm chart referenced here.
:::
### Running
## Running
1. Add the Superset helm repository
@ -89,9 +95,9 @@ Depending how you configured external access, the URL will vary. Once you've ide
- user: `admin`
- password: `admin`
### Important settings
## Important settings
#### Security settings
### Security settings
Default security settings and passwords are included but you **MUST** update them to run `prod` instances, in particular:
@ -135,7 +141,7 @@ Superset uses [Scarf Gateway](https://about.scarf.sh/scarf-gateway) to collect t
To opt-out of this data collection in your Helm-based installation, edit the `repository:` line in your `helm/superset/values.yaml` file, replacing `apachesuperset.docker.scarf.sh/apache/superset` with `apache/superset` to pull the image directly from Docker Hub.
:::
#### Dependencies
### Dependencies
Install additional packages and do any other bootstrap configuration in the bootstrap script.
For production clusters it's recommended to build own image with this step done in CI.
@ -161,7 +167,7 @@ bootstrapScript: |
if [ ! -f ~/bootstrap ]; then echo "Running Superset with uid {{ .Values.runAsUser }}" > ~/bootstrap; fi
```
#### superset_config.py
### superset_config.py
The default `superset_config.py` is fairly minimal and you will very likely need to extend it. This is done by specifying one or more key/value entries in `configOverrides`, e.g.:
@ -181,7 +187,7 @@ The entire `superset_config.py` will be installed as a secret, so it is safe to
Full python files can be provided by running `helm upgrade --install --values my-values.yaml --set-file configOverrides.oauth=set_oauth.py`
#### Environment Variables
### Environment Variables
Those can be passed as key/values either with `extraEnv` or `extraSecretEnv` if they're sensitive. They can then be referenced from `superset_config.py` using e.g. `os.environ.get("VAR")`.
@ -206,7 +212,7 @@ configOverrides:
SMTP_PASSWORD = os.getenv("SMTP_PASSWORD","superset")
```
#### System packages
### System packages
If new system packages are required, they can be installed before application startup by overriding the container's `command`, e.g.:
@ -225,7 +231,7 @@ supersetWorker:
. {{ .Values.configMountPath }}/superset_bootstrap.sh; celery --app=superset.tasks.celery_app:app worker
```
#### Data sources
### Data sources
Data source definitions can be automatically declared by providing key/value yaml definitions in `extraConfigs`:
@ -246,9 +252,9 @@ extraConfigs:
Those will also be mounted as secrets and can include sensitive parameters.
### Configuration Examples
## Configuration Examples
#### Setting up OAuth
### Setting up OAuth
:::note
@ -302,11 +308,11 @@ configOverrides:
AUTH_USER_REGISTRATION_ROLE = "Admin"
```
#### Enable Alerts and Reports
### Enable Alerts and Reports
For this, as per the [Alerts and Reports doc](/docs/configuration/alerts-reports), you will need to:
##### Install a supported webdriver in the Celery worker
#### Install a supported webdriver in the Celery worker
This is done either by using a custom image that has the webdriver pre-installed, or installing at startup time by overriding the `command`. Here's a working example for `chromedriver`:
@ -335,7 +341,7 @@ supersetWorker:
. {{ .Values.configMountPath }}/superset_bootstrap.sh; celery --app=superset.tasks.celery_app:app worker
```
##### Run the Celery beat
#### Run the Celery beat
This pod will trigger the scheduled tasks configured in the alerts and reports UI section:
@ -344,7 +350,7 @@ supersetCeleryBeat:
enabled: true
```
##### Configure the appropriate Celery jobs and SMTP/Slack settings
#### Configure the appropriate Celery jobs and SMTP/Slack settings
```yaml
extraEnv:
@ -428,7 +434,7 @@ configOverrides:
"--disable-extensions",
]
```
#### Load the Examples data and dashboards
### Load the Examples data and dashboards
If you are trying Superset out and want some data and dashboards to explore, you can load some examples by creating a `my_values.yaml` and deploying it as described above in the **Configure your setting overrides** step of the **Running** section.
To load the examples, add the following to the `my_values.yaml` file:
```yaml

View File

@ -5,11 +5,16 @@ sidebar_position: 2
version: 1
---
## Installing Superset from PyPI
import useBaseUrl from "@docusaurus/useBaseUrl";
# Installing Superset from PyPI
<img src={useBaseUrl("/img/pypi.png" )} width="150" />
<br /><br />
This page describes how to install Superset using the `apache-superset` package [published on PyPI](https://pypi.org/project/apache-superset/).
### OS Dependencies
## OS Dependencies
Superset stores database connection information in its metadata database. For that purpose, we use
the cryptography Python library to encrypt connection passwords. Unfortunately, this library has OS
@ -91,7 +96,7 @@ export CFLAGS="-I$(brew --prefix openssl)/include"
These will now be available when pip installing requirements.
### Python Virtual Environment
## Python Virtual Environment
We highly recommend installing Superset inside of a virtual environment. Python ships with
`virtualenv` out of the box. If you're using [pyenv](https://github.com/pyenv/pyenv), you can install [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv). Or you can install it with `pip`:

View File

@ -5,9 +5,9 @@ sidebar_position: 4
version: 1
---
## Upgrading Superset
# Upgrading Superset
### Docker Compose
## Docker Compose
First make sure to wind down the running containers in Docker Compose:
@ -27,7 +27,7 @@ Then, restart the containers and any changed Docker images will be automatically
docker compose up
```
### Updating Superset Manually
## Updating Superset Manually
To upgrade superset in a native installation, run the following commands:
@ -35,7 +35,7 @@ To upgrade superset in a native installation, run the following commands:
pip install apache-superset --upgrade
```
## Upgrading Metadata Database
## Upgrading the Metadata Database
Migrate the metadata database by running:

View File

@ -1,67 +0,0 @@
---
title: Introduction
hide_title: true
sidebar_position: 1
---
## What is Apache Superset?
Apache Superset is a modern, enterprise-ready business intelligence web application. It
is fast, lightweight, intuitive, and loaded with options that make it easy for users of all skill
sets to explore and visualize their data, from simple pie charts to highly detailed deck.gl
geospatial charts.
Here are a **few different ways you can get started with Superset**:
- Try a [Quickstart deployment](/docs/quickstart), powered by [Docker Compose](https://docs.docker.com/compose/)
- Install Superset [from PyPI](/docs/installation/pypi/)
- Deploy Superset [with Kubernetes](/docs/installation/kubernetes)
- Download the [source code from Apache Foundation's website](https://dist.apache.org/repos/dist/release/superset/)
#### Video Overview
<video src="https://superset.staged.apache.org/superset-video-4k.mp4" width="100%" height="auto" controls preload="none">
https://superset.staged.apache.org/superset-video-4k.mp4
</video>
#### Features
Superset provides:
- An intuitive interface for visualizing datasets and crafting interactive dashboards
- A wide array of beautiful visualizations to showcase your data
- Code-free visualization builder to extract and present datasets
- A world-class SQL IDE for preparing data for visualization, including a rich metadata browser
- A lightweight semantic layer which empowers data analysts to quickly define custom dimensions and metrics
- Out-of-the-box support for [most SQL-speaking databases](http://localhost:3000/docs/configuration/databases#installing-database-drivers)
- Seamless, in-memory asynchronous caching and queries
- An extensible security model that allows configuration of very intricate rules on who can access which product features and datasets.
- Integration with major authentication backends (database, OpenID, LDAP, OAuth, REMOTE_USER, etc)
- The ability to add custom visualization plugins
- An API for programmatic customization
- A cloud-native architecture designed from the ground up for scale
#### Backend Technology
Superset is cloud-native and designed to be highly available. It was designed to scale out to large,
distributed environments and works very well inside containers. While you can easily test drive
Superset on a modest setup or simply on your laptop, theres virtually no limit around scaling out
the platform.
Superset is also cloud-native in the sense that it is flexible and lets you choose the:
- Web server (Gunicorn, Nginx, Apache),
- Metadata database engine (PostgreSQL, MySQL, MariaDB),
- Message queue (Celery, Redis, RabbitMQ, SQS, etc.),
- Results backend (Redis, S3, Memcached, etc.),
- Caching layer (Redis, Memcached, etc.)
Superset also works well with [event-logging](/docs/configuration/event-logging/)
services like StatsD, NewRelic, and DataDog.
Superset is currently run at scale at many companies. For example, Superset is run in Airbnbs
production environment inside Kubernetes and serves 600+ daily active users viewing over 100K charts
a day.
You can find a partial list of industries and companies embracing Superset
[on this page in GitHub](https://github.com/apache/superset/blob/master/RESOURCES/INTHEWILD.md).

View File

@ -231,6 +231,7 @@ const config = {
items: [
{
label: 'Documentation',
to: '/docs/intro',
items: [
{
label: 'Getting Started',
@ -244,6 +245,7 @@ const config = {
},
{
label: 'Community',
to: '/community',
items: [
{
label: 'Resources',

View File

@ -5,8 +5,9 @@
"license": "Apache-2.0",
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"_init": "cp ../README.md docs/intro.md",
"start": "npm run _init && docusaurus start",
"build": "npm run _init && docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",

View File

@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
// @ts-nocheck
import React, { useRef, useState, useEffect } from 'react';
import Layout from '@theme/Layout';
import Link from '@docusaurus/Link';
@ -28,6 +29,8 @@ import SectionHeader from '../components/SectionHeader';
import BlurredSection from '../components/BlurredSection';
import '../styles/main.less';
// @ts-ignore
const features = [
{
image: 'powerful-yet-easy.jpg',

View File

@ -39,6 +39,12 @@
font-weight: 700;
font-style: bold;
}
/* Hiding ugly linkout icons */
ul.dropdown__menu svg {
display: none;
}
:root {
--ifm-color-primary: #20a7c9;
--ifm-color-primary-dark: #1985a0;
@ -60,4 +66,6 @@
--ifm-border-color: #ededed;
--ifm-primary-text: #484848;
--ifm-secondary-text: #5f5f5f;
--ifm-code-padding-vertical: 3px;
--ifm-code-padding-horizontal: 5px;
}

View File

@ -63,3 +63,5 @@ RewriteRule ^docs/installation/async-queries-celery/$ /docs/configuration/async-
RewriteRule ^docs/installation/event-logging/$ /docs/configuration/event-logging [R=301,L]
RewriteRule ^docs/databases.*$ /docs/configuration/databases [R=301,L]
RewriteRule ^docs/configuration/setup-ssh-tunneling$ /docs/configuration/networking-settings [R=301,L]

BIN
docs/static/img/databases/databend.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
docs/static/img/databases/db2.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
docs/static/img/databases/firebolt.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

51
docs/static/img/databases/ibm-db2.svg vendored Normal file
View File

@ -0,0 +1,51 @@
<svg width="600" height="263" viewBox="0 0 600 263" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.0488281 224.047H300.809V38.0058H0.0488281V224.047Z" fill="#1B1918"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M246.245 96.0585H211.238L213.393 90.0245H246.245V96.0585Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M152.919 90.0216L185.422 90.0188L187.551 96.0698C187.566 96.0613 152.93 96.0782 152.93 96.0698C152.93 96.0613 152.908 90.0245 152.919 90.0245V90.0216Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M127.104 90.0217C132.462 90.5372 137.118 92.4471 141.085 96.0698C141.085 96.0698 82.1699 96.0754 82.1699 96.0698C82.1699 96.0613 82.1699 90.0217 82.1699 90.0217H127.104Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M35.9355 96.0585H76.8667V90.0217H35.9355V96.0585Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M246.244 107.386H207.223C207.223 107.386 209.352 101.38 209.338 101.377H246.244V107.386Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M191.571 107.391H152.916V101.377H189.453L191.571 107.391Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M145.674 101.374C146.452 103.357 147.37 105.053 147.37 107.383H82.1816V101.374H145.674Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M35.9355 107.383H76.8667V101.374H35.9355V107.383Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M203.23 118.738L205.374 112.704L234.671 112.713V118.724L203.23 118.738Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M193.453 112.701L195.585 118.738H164.443V112.701H193.453Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M147.886 112.701C147.886 114.769 147.627 116.927 147.024 118.738H129.176V112.701H147.886Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M47.3438 118.735H64.936V112.73H47.3438V118.735Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M94.0215 118.735H111.583V112.701H94.0215V118.735Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M181.743 125.254C181.743 125.254 181.745 129.823 181.743 129.832H164.443V123.826H197.411L199.459 129.426C199.467 129.429 201.431 123.812 201.436 123.823H234.663V129.832H217.445C217.445 129.823 217.437 125.257 217.437 125.257L215.842 129.832L183.331 129.823L181.743 125.254Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M94.0215 123.823H144.437C143.333 125.834 141.333 128.279 139.434 129.832C139.434 129.832 94.0215 129.84 94.0215 129.832C94.0215 129.823 94.0215 123.834 94.0215 123.823Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M47.3438 129.832H64.936V123.823H47.3438V129.832Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M217.447 141.156H234.665V135.15H217.447V141.156Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M181.743 135.15H164.443V141.156C164.432 141.153 181.745 141.159 181.745 141.156C181.745 141.153 181.765 135.15 181.743 135.15Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M213.97 135.15C213.891 135.142 211.953 141.153 211.871 141.156L187.349 141.167C187.33 141.159 185.194 135.142 185.191 135.15H213.97Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M94.0195 135.147H139.351C141.418 136.874 143.289 139.001 144.754 141.156C144.838 141.153 94.0223 141.159 94.0223 141.156C94.0223 141.153 94.0195 135.156 94.0195 135.147Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M64.9323 141.156V135.147H47.3711C47.3711 135.147 47.3767 141.153 47.3711 141.153C47.3683 141.153 64.9239 141.156 64.9323 141.156Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M217.447 152.483H234.662V146.474H217.447V152.483Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M164.441 152.48H181.743V146.474H164.441V152.48Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M207.846 152.511C207.851 152.483 209.97 146.469 210.001 146.474H189.155C189.118 146.472 191.293 152.483 191.293 152.483C191.293 152.483 207.84 152.537 207.846 152.511Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M94.0227 152.48C94.0227 152.506 94.0199 146.474 94.0227 146.474H111.846C111.846 146.474 111.86 152.483 111.846 152.483C111.829 152.483 94.0227 152.478 94.0227 152.48Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M147.254 146.474C148.116 148.283 148.204 150.441 148.375 152.509H129.49V146.474H147.254Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M47.3711 152.48H64.9323V146.474H47.3711V152.48Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M217.447 163.577H246.246V157.568H217.447V163.577Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M152.916 163.577H181.742V157.568H152.916V163.577Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M203.972 163.577H195.18L193.07 157.568H206.006L203.972 163.577Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M35.9317 157.568V163.574H76.8346C76.8515 163.585 76.8149 157.571 76.8346 157.571C76.8515 157.571 35.8866 157.568 35.9317 157.568Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M147.627 157.568C147.196 159.551 146.802 161.965 145.354 163.577L144.813 163.574H82.1797V157.568H147.627Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M199.986 174.915H199.178L197.121 168.892H202.096L199.986 174.915Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M217.447 174.929H246.246V168.892H217.447V174.929Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M82.1699 174.915V168.904C82.1699 168.904 141.262 168.912 141.431 168.912C137.462 172.704 132.02 174.845 126.157 174.929L82.1784 174.918L82.1699 174.915Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M152.916 174.929H181.742V168.892H152.916V174.929Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M76.8348 168.92C76.8348 168.92 76.8151 174.915 76.8348 174.915C76.8517 174.915 35.9459 174.94 35.9319 174.926C35.9234 174.915 35.9431 168.904 35.9319 168.904C35.9234 168.904 76.8151 168.94 76.8348 168.92Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M256.196 162.731C257.3 162.731 258.379 163.013 259.436 163.585C260.486 164.148 261.309 164.963 261.895 166.019C262.484 167.075 262.777 168.177 262.777 169.323C262.777 170.456 262.489 171.551 261.909 172.597C261.329 173.645 260.52 174.459 259.472 175.036C258.427 175.616 257.334 175.907 256.196 175.907C255.055 175.907 253.962 175.616 252.917 175.036C251.869 174.459 251.058 173.645 250.475 172.597C249.895 171.551 249.602 170.456 249.602 169.323C249.602 168.177 249.897 167.075 250.489 166.019C251.08 164.963 251.903 164.148 252.954 163.585C254.01 163.013 255.089 162.731 256.196 162.731ZM256.196 163.822C255.269 163.822 254.368 164.061 253.492 164.534C252.616 165.008 251.931 165.686 251.435 166.568C250.94 167.45 250.695 168.368 250.695 169.323C250.695 170.273 250.937 171.18 251.424 172.05C251.909 172.921 252.588 173.599 253.461 174.087C254.334 174.571 255.247 174.816 256.196 174.816C257.143 174.816 258.055 174.571 258.929 174.087C259.802 173.599 260.481 172.921 260.963 172.05C261.447 171.18 261.687 170.273 261.687 169.323C261.687 168.368 261.439 167.45 260.948 166.568C260.455 165.686 259.771 165.008 258.892 164.534C258.013 164.061 257.115 163.822 256.196 163.822ZM253.303 172.957V165.878H255.74C256.574 165.878 257.176 165.943 257.548 166.075C257.923 166.205 258.219 166.433 258.441 166.76C258.664 167.084 258.774 167.43 258.774 167.796C258.774 168.312 258.588 168.765 258.216 169.146C257.847 169.532 257.354 169.746 256.743 169.794C256.991 169.898 257.193 170.022 257.343 170.168C257.63 170.444 257.979 170.912 258.393 171.571L259.255 172.957H257.867L257.236 171.842C256.743 170.963 256.34 170.413 256.036 170.191C255.827 170.03 255.523 169.951 255.12 169.954H254.447V172.957H253.303ZM254.447 168.971H255.836C256.5 168.971 256.954 168.873 257.193 168.675C257.436 168.478 257.557 168.216 257.557 167.895C257.557 167.687 257.498 167.498 257.382 167.334C257.267 167.168 257.106 167.044 256.9 166.965C256.692 166.884 256.309 166.844 255.748 166.844H254.447V168.971Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M300.809 222.993H600.056V37.9718H300.809V222.993Z" fill="#09AF05"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M352.369 169.633V86.9004H375.215C404.36 86.9004 418.952 100.332 418.952 127.232C418.952 139.993 414.895 150.255 406.802 158.013C398.709 165.751 387.878 169.633 374.288 169.633H352.369ZM362.06 95.6641V160.869H374.407C385.258 160.869 393.686 157.954 399.731 152.145C405.78 146.334 408.791 138.102 408.791 127.448C408.791 106.259 397.526 95.6641 374.978 95.6641H362.06ZM435.22 169.633V86.9004H458.753C465.903 86.9004 471.593 88.6526 475.768 92.14C479.963 95.6444 482.07 100.214 482.07 105.825C482.07 110.513 480.791 114.589 478.25 118.054C475.709 121.521 472.224 123.983 467.754 125.44V125.677C473.326 126.327 477.796 128.434 481.146 131.978C484.492 135.542 486.166 140.17 486.166 145.863C486.166 152.931 483.625 158.664 478.546 163.055C473.464 167.444 467.064 169.633 459.325 169.633H435.22ZM444.908 95.6641V122.389H454.835C460.131 122.389 464.306 121.107 467.359 118.547C470.393 115.986 471.909 112.383 471.909 107.715C471.909 99.6812 466.63 95.6641 456.035 95.6641H444.908ZM444.908 131.091V160.869H458.063C463.756 160.869 468.168 159.509 471.298 156.833C474.45 154.134 476.005 150.43 476.005 145.745C476.005 135.975 469.348 131.091 456.035 131.091H444.908ZM547.492 169.633H497.628V161.202L521.753 137.04C527.897 130.877 532.308 125.755 534.928 121.659C537.565 117.564 538.886 113.192 538.886 108.524C538.886 103.757 537.525 100.076 534.79 97.4557C532.052 94.8359 528.173 93.5373 523.13 93.5373C515.744 93.5373 508.676 96.6867 501.902 102.988V93.064C508.361 88.0216 515.882 85.5032 524.469 85.5032C531.855 85.5032 537.644 87.5117 541.878 91.509C546.112 95.5064 548.238 100.884 548.238 107.617C548.238 112.915 546.762 118.093 543.847 123.155C540.914 128.217 535.675 134.499 528.094 142.001L508.992 160.869V161.086H547.492V169.633Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M557.768 163.258C558.873 163.258 559.952 163.543 561.005 164.112C562.059 164.678 562.881 165.489 563.467 166.546C564.053 167.602 564.349 168.706 564.349 169.85C564.349 170.985 564.059 172.078 563.479 173.123C562.901 174.171 562.09 174.985 561.045 175.563C560 176.146 558.907 176.433 557.768 176.433C556.628 176.433 555.535 176.146 554.487 175.563C553.442 174.985 552.627 174.171 552.047 173.123C551.467 172.078 551.174 170.985 551.174 169.85C551.174 168.706 551.47 167.602 552.058 166.546C552.653 165.489 553.475 164.678 554.526 164.112C555.58 163.543 556.659 163.258 557.768 163.258ZM557.768 164.348C556.842 164.348 555.937 164.588 555.061 165.061C554.185 165.534 553.501 166.213 553.008 167.098C552.512 167.98 552.264 168.895 552.264 169.85C552.264 170.799 552.509 171.709 552.994 172.58C553.481 173.447 554.16 174.129 555.033 174.614C555.906 175.098 556.816 175.343 557.768 175.343C558.715 175.343 559.628 175.098 560.501 174.614C561.371 174.129 562.053 173.447 562.535 172.58C563.017 171.709 563.259 170.799 563.259 169.85C563.259 168.895 563.011 167.98 562.521 167.098C562.028 166.213 561.343 165.534 560.464 165.061C559.585 164.588 558.687 164.348 557.768 164.348ZM554.875 173.484V166.405H557.312C558.146 166.405 558.749 166.47 559.121 166.602C559.495 166.732 559.791 166.96 560.014 167.287C560.233 167.61 560.346 167.957 560.346 168.323C560.346 168.839 560.16 169.292 559.788 169.673C559.419 170.058 558.926 170.273 558.312 170.32C558.563 170.425 558.766 170.549 558.915 170.695C559.199 170.971 559.549 171.442 559.963 172.098L560.828 173.484H559.439L558.808 172.371C558.312 171.49 557.912 170.94 557.608 170.72C557.399 170.557 557.095 170.478 556.692 170.481H556.019V173.484H554.875ZM556.019 169.498H557.408C558.073 169.498 558.523 169.399 558.766 169.202C559.008 169.005 559.129 168.743 559.129 168.422C559.129 168.213 559.07 168.025 558.954 167.861C558.836 167.695 558.676 167.574 558.47 167.492C558.261 167.413 557.881 167.371 557.321 167.371H556.019V169.498Z" fill="white"/>
</g>
<defs>
<clipPath id="clip0">
<rect width="600" height="186.058" fill="white" transform="translate(0 38)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

BIN
docs/static/img/databases/mariadb.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
docs/static/img/databases/monet-db.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 KiB

BIN
docs/static/img/databases/mssql.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
docs/static/img/databases/mysql.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
docs/static/img/databases/pinot.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

BIN
docs/static/img/databases/postgresql.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
docs/static/img/databases/presto.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
docs/static/img/databases/redshift.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
docs/static/img/databases/snowflake.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
docs/static/img/databases/sybase.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
docs/static/img/docker-compose.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

BIN
docs/static/img/docker-compose.webp vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
docs/static/img/k8s.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
docs/static/img/pypi.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
docs/static/img/screenshots/explore.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 KiB

BIN
docs/static/img/screenshots/gallery.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 KiB

BIN
docs/static/img/screenshots/sql_lab.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 KiB

View File

@ -3,5 +3,11 @@
"extends": "@tsconfig/docusaurus/tsconfig.json",
"compilerOptions": {
"baseUrl": "."
},
"jsx": "react-jsx",
"moduleResolution": "node",
"baseUrl": "./",
"paths": {
"*": ["src/*", "node_modules/*"]
}
}

File diff suppressed because it is too large Load Diff

View File

@ -48,6 +48,7 @@
"@superset-ui/plugin-chart-word-cloud": "file:./plugins/plugin-chart-word-cloud",
"@superset-ui/switchboard": "file:./packages/superset-ui-switchboard",
"@types/d3-format": "^3.0.1",
"@types/d3-time-format": "^3.0.1",
"@visx/axis": "^3.8.0",
"@visx/grid": "^3.5.0",
"@visx/responsive": "^3.0.0",
@ -5381,6 +5382,11 @@
"resolved": "https://registry.npmjs.org/@types/d3-format/-/d3-format-1.4.2.tgz",
"integrity": "sha512-WeGCHAs7PHdZYq6lwl/+jsl+Nfc1J2W1kNcMeIMYzQsT6mtBDBgtJ/rcdjZ0k0rVIvqEZqhhuD5TK/v3P2gFHQ=="
},
"node_modules/@encodable/format/node_modules/@types/d3-time-format": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
"integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
},
"node_modules/@encodable/format/node_modules/d3-array": {
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz",
@ -22702,9 +22708,9 @@
"integrity": "sha512-ULX7LoqXTCYtM+tLYOaeAJK7IwCT+4Gxlm2MaH0ErKLi07R5lh8NHCAyWcDkCCmx1AfRcBEV6H9QE9R25uP7jw=="
},
"node_modules/@types/d3-time-format": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
"integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-3.0.1.tgz",
"integrity": "sha512-5GIimz5IqaRsdnxs4YlyTZPwAMfALu/wA4jqSiuqgdbCxUZ2WjrnwANqOtoBJQgeaUTdYNfALJO0Yb0YrDqduA=="
},
"node_modules/@types/d3-voronoi": {
"version": "1.1.12",
@ -67780,6 +67786,11 @@
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz",
"integrity": "sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA=="
},
"packages/superset-ui-core/node_modules/@types/d3-time-format": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
"integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
},
"packages/superset-ui-core/node_modules/@types/math-expression-evaluator": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@types/math-expression-evaluator/-/math-expression-evaluator-1.3.3.tgz",
@ -74975,6 +74986,11 @@
"resolved": "https://registry.npmjs.org/@types/d3-format/-/d3-format-1.4.2.tgz",
"integrity": "sha512-WeGCHAs7PHdZYq6lwl/+jsl+Nfc1J2W1kNcMeIMYzQsT6mtBDBgtJ/rcdjZ0k0rVIvqEZqhhuD5TK/v3P2gFHQ=="
},
"@types/d3-time-format": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
"integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
},
"d3-array": {
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz",
@ -86396,6 +86412,11 @@
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz",
"integrity": "sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA=="
},
"@types/d3-time-format": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
"integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
},
"@types/math-expression-evaluator": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@types/math-expression-evaluator/-/math-expression-evaluator-1.3.3.tgz",
@ -89663,9 +89684,9 @@
"integrity": "sha512-ULX7LoqXTCYtM+tLYOaeAJK7IwCT+4Gxlm2MaH0ErKLi07R5lh8NHCAyWcDkCCmx1AfRcBEV6H9QE9R25uP7jw=="
},
"@types/d3-time-format": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
"integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-3.0.1.tgz",
"integrity": "sha512-5GIimz5IqaRsdnxs4YlyTZPwAMfALu/wA4jqSiuqgdbCxUZ2WjrnwANqOtoBJQgeaUTdYNfALJO0Yb0YrDqduA=="
},
"@types/d3-voronoi": {
"version": "1.1.12",

View File

@ -114,6 +114,7 @@
"@superset-ui/plugin-chart-word-cloud": "file:./plugins/plugin-chart-word-cloud",
"@superset-ui/switchboard": "file:./packages/superset-ui-switchboard",
"@types/d3-format": "^3.0.1",
"@types/d3-time-format": "^3.0.1",
"@visx/axis": "^3.8.0",
"@visx/grid": "^3.5.0",
"@visx/responsive": "^3.0.0",

View File

@ -18,7 +18,7 @@
*/
import {
t,
smartDateFormatter,
SMART_DATE_ID,
NumberFormats,
getNumberFormatter,
} from '@superset-ui/core';
@ -64,7 +64,7 @@ export const D3_TIME_FORMAT_DOCS = t(
);
export const D3_TIME_FORMAT_OPTIONS: [string, string][] = [
[smartDateFormatter.id, t('Adaptive formatting')],
[SMART_DATE_ID, t('Adaptive formatting')],
['%d/%m/%Y', '%d/%m/%Y | 14/01/2019'],
['%m/%d/%Y', '%m/%d/%Y | 01/14/2019'],
['%Y-%m-%d', '%Y-%m-%d | 2019-01-14'],

View File

@ -0,0 +1,65 @@
/**
* 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 { TimeLocaleDefinition } from 'd3-time-format';
export const DEFAULT_D3_TIME_FORMAT: TimeLocaleDefinition = {
dateTime: '%x, %X',
date: '%-m/%-d/%Y',
time: '%-I:%M:%S %p',
periods: ['AM', 'PM'],
days: [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
],
shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
months: [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
],
shortMonths: [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
],
};

View File

@ -4,19 +4,22 @@
* 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
* '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
* '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 { TimeLocaleDefinition } from 'd3-time-format';
import { RegistryWithDefaultKey, OverwritePolicy } from '../models';
import { DEFAULT_D3_TIME_FORMAT } from './D3FormatConfig';
import TimeFormats, { LOCAL_PREFIX } from './TimeFormats';
import createD3TimeFormatter from './factories/createD3TimeFormatter';
import TimeFormatter from './TimeFormatter';
@ -25,12 +28,21 @@ export default class TimeFormatterRegistry extends RegistryWithDefaultKey<
TimeFormatter,
TimeFormatter
> {
d3Format: TimeLocaleDefinition;
constructor() {
super({
initialDefaultKey: TimeFormats.DATABASE_DATETIME,
name: 'TimeFormatter',
overwritePolicy: OverwritePolicy.Warn,
});
this.d3Format = DEFAULT_D3_TIME_FORMAT;
}
setD3Format(d3Format: Partial<TimeLocaleDefinition>) {
this.d3Format = { ...DEFAULT_D3_TIME_FORMAT, ...d3Format };
return this;
}
get(format?: string) {
@ -47,7 +59,13 @@ export default class TimeFormatterRegistry extends RegistryWithDefaultKey<
// Create new formatter if does not exist
const useLocalTime = targetFormat.startsWith(LOCAL_PREFIX);
const formatString = targetFormat.replace(LOCAL_PREFIX, '');
const formatter = createD3TimeFormatter({ formatString, useLocalTime });
const locale = this.d3Format;
const formatter = createD3TimeFormatter({
formatString,
useLocalTime,
locale,
});
this.registerValue(targetFormat, formatter);
return formatter;

View File

@ -16,8 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
import { utcFormat, timeFormat } from 'd3-time-format';
import {
timeFormatLocale,
TimeLocaleDefinition,
timeFormat,
utcFormat,
} from 'd3-time-format';
import { utcUtils, localTimeUtils } from '../utils/d3Time';
import TimeFormatter from '../TimeFormatter';
@ -38,12 +42,14 @@ export default function createMultiFormatter({
description,
formats = {},
useLocalTime = false,
locale,
}: {
id: string;
label?: string;
description?: string;
formats?: FormatsByStep;
useLocalTime?: boolean;
locale?: TimeLocaleDefinition;
}) {
const {
millisecond = '.%L',
@ -56,16 +62,23 @@ export default function createMultiFormatter({
year = '%Y',
} = formats;
const format = useLocalTime ? timeFormat : utcFormat;
let formatFunc;
const formatMillisecond = format(millisecond);
const formatSecond = format(second);
const formatMinute = format(minute);
const formatHour = format(hour);
const formatDay = format(day);
const formatFirstDayOfWeek = format(week);
const formatMonth = format(month);
const formatYear = format(year);
if (typeof locale === 'undefined') {
formatFunc = useLocalTime ? timeFormat : utcFormat;
} else {
const formatLocale = timeFormatLocale(locale);
formatFunc = useLocalTime ? formatLocale.format : formatLocale.utcFormat;
}
const formatMillisecond = formatFunc(millisecond);
const formatSecond = formatFunc(second);
const formatMinute = formatFunc(minute);
const formatHour = formatFunc(hour);
const formatDay = formatFunc(day);
const formatFirstDayOfWeek = formatFunc(week);
const formatMonth = formatFunc(month);
const formatYear = formatFunc(year);
const {
hasMillisecond,

View File

@ -17,21 +17,25 @@
* under the License.
*/
import { TimeLocaleDefinition } from 'd3-time-format';
import createMultiFormatter from '../factories/createMultiFormatter';
const smartDateFormatter = createMultiFormatter({
id: 'smart_date',
label: 'Adaptative Formatting',
formats: {
millisecond: '.%Lms',
second: ':%Ss',
minute: '%I:%M',
hour: '%I %p',
day: '%a %d',
week: '%b %d',
month: '%B',
year: '%Y',
},
});
export const SMART_DATE_ID = 'smart_date';
export default smartDateFormatter;
export function createSmartDateFormatter(locale?: TimeLocaleDefinition) {
return createMultiFormatter({
id: SMART_DATE_ID,
label: 'Adaptative Formatting',
formats: {
millisecond: '.%Lms',
second: ':%Ss',
minute: '%I:%M',
hour: '%I %p',
day: '%a %d',
week: '%b %d',
month: '%B',
year: '%Y',
},
locale,
});
}

View File

@ -17,21 +17,27 @@
* under the License.
*/
import { TimeLocaleDefinition } from 'd3-time-format';
import createMultiFormatter from '../factories/createMultiFormatter';
const smartDateDetailedFormatter = createMultiFormatter({
id: 'smart_date_detailed',
label: 'Detailed adaptive formatter',
formats: {
millisecond: '%Y-%m-%d %H:%M:%S.%L',
second: '%Y-%m-%d %H:%M:%S',
minute: '%Y-%m-%d %H:%M',
hour: '%Y-%m-%d %H:%M',
day: '%Y-%m-%d',
week: '%Y-%m-%d',
month: '%Y-%m-%d',
year: '%Y',
},
});
export const SMART_DATE_DETAILED_ID = 'smart_date_detailed';
export default smartDateDetailedFormatter;
export function createSmartDateDetailedFormatter(
locale?: TimeLocaleDefinition,
) {
return createMultiFormatter({
id: 'smart_date_detailed',
label: 'Detailed adaptive formatter',
formats: {
millisecond: '%Y-%m-%d %H:%M:%S.%L',
second: '%Y-%m-%d %H:%M:%S',
minute: '%Y-%m-%d %H:%M',
hour: '%Y-%m-%d %H:%M',
day: '%Y-%m-%d',
week: '%Y-%m-%d',
month: '%Y-%m-%d',
year: '%Y',
},
locale,
});
}

View File

@ -17,21 +17,25 @@
* under the License.
*/
import { TimeLocaleDefinition } from 'd3-time-format';
import createMultiFormatter from '../factories/createMultiFormatter';
const smartDateFormatter = createMultiFormatter({
id: 'smart_date_verbose',
label: 'Verbose Adaptative Formatting',
formats: {
millisecond: '.%L',
second: '%a %b %d, %I:%M:%S %p',
minute: '%a %b %d, %I:%M %p',
hour: '%a %b %d, %I %p',
day: '%a %b %-e',
week: '%a %b %-e',
month: '%b %Y',
year: '%Y',
},
});
export const SMART_DATE_VERBOSE_ID = 'smart_date_verbose';
export default smartDateFormatter;
export function createSmartDateVerboseFormatter(locale?: TimeLocaleDefinition) {
return createMultiFormatter({
id: SMART_DATE_VERBOSE_ID,
label: 'Verbose Adaptative Formatting',
formats: {
millisecond: '.%L',
second: '%a %b %d, %I:%M:%S %p',
minute: '%a %b %d, %I:%M %p',
hour: '%a %b %d, %I %p',
day: '%a %b %-e',
week: '%a %b %-e',
month: '%b %Y',
year: '%Y',
},
locale,
});
}

View File

@ -19,6 +19,7 @@
export { default as TimeFormats, LOCAL_PREFIX } from './TimeFormats';
export { default as TimeFormatter, PREVIEW_TIME } from './TimeFormatter';
export { DEFAULT_D3_TIME_FORMAT } from './D3FormatConfig';
export {
default as getTimeFormatterRegistry,
@ -32,9 +33,18 @@ export {
export { default as createD3TimeFormatter } from './factories/createD3TimeFormatter';
export { default as createMultiFormatter } from './factories/createMultiFormatter';
export { default as smartDateFormatter } from './formatters/smartDate';
export { default as smartDateDetailedFormatter } from './formatters/smartDateDetailed';
export { default as smartDateVerboseFormatter } from './formatters/smartDateVerbose';
export {
SMART_DATE_ID,
createSmartDateFormatter,
} from './formatters/smartDate';
export {
SMART_DATE_DETAILED_ID,
createSmartDateDetailedFormatter,
} from './formatters/smartDateDetailed';
export {
SMART_DATE_VERBOSE_ID,
createSmartDateVerboseFormatter,
} from './formatters/smartDateVerbose';
export { default as finestTemporalGrainFormatter } from './formatters/finestTemporalGrain';
export { default as normalizeTimestamp } from './utils/normalizeTimestamp';

View File

@ -17,8 +17,10 @@
* under the License.
*/
import { TimeLocaleDefinition } from 'd3-time-format';
import { TimeFormats, TimeFormatter, PREVIEW_TIME } from '@superset-ui/core';
import TimeFormatterRegistry from '../../src/time-format/TimeFormatterRegistry';
import { DEFAULT_D3_TIME_FORMAT } from '../../src/time-format';
describe('TimeFormatterRegistry', () => {
let registry: TimeFormatterRegistry;
@ -78,4 +80,108 @@ describe('TimeFormatterRegistry', () => {
);
});
});
describe('.setD3Format(d3Format)', () => {
describe('when partial value is specified', () => {
const timeFormat: Partial<TimeLocaleDefinition> = {
days: [
'Domingo',
'Segunda',
'Terça',
'Quarta',
'Quinta',
'Sexta',
'Sábado',
],
};
beforeEach(() => {
registry.setD3Format(timeFormat);
});
it('sets the specified value and default', () => {
expect(registry.d3Format).toEqual({
...DEFAULT_D3_TIME_FORMAT,
...timeFormat,
});
});
it('does not change short days of week name format', () => {
expect(registry.format('%a', PREVIEW_TIME)).toEqual('Tue');
});
it('changes full days of week name format', () => {
expect(registry.format('%A', PREVIEW_TIME)).toEqual('Terça');
});
it('does not change months format', () => {
expect(registry.format('%b', PREVIEW_TIME)).toEqual('Feb');
expect(registry.format('%B', PREVIEW_TIME)).toEqual('February');
});
});
describe('when full value is specified', () => {
const timeFormat: TimeLocaleDefinition = {
dateTime: '%A, %e de %B de %Y. %X',
date: '%d/%m/%Y',
time: '%H:%M:%S',
periods: ['AM', 'PM'],
days: [
'Domingo',
'Segunda',
'Terça',
'Quarta',
'Quinta',
'Sexta',
'Sábado',
],
shortDays: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
months: [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
],
shortMonths: [
'Jan',
'Fev',
'Mar',
'Abr',
'Mai',
'Jun',
'Jul',
'Ago',
'Set',
'Out',
'Nov',
'Dez',
],
};
beforeEach(() => {
registry.setD3Format(timeFormat);
});
it('sets the specified value ignoring default', () => {
expect(registry.d3Format).toEqual(timeFormat);
});
it('changes days of week format', () => {
expect(registry.format('%a', PREVIEW_TIME)).toEqual('Ter');
expect(registry.format('%A', PREVIEW_TIME)).toEqual('Terça');
});
it('changes months format', () => {
expect(registry.format('%b', PREVIEW_TIME)).toEqual('Fev');
expect(registry.format('%B', PREVIEW_TIME)).toEqual('Fevereiro');
});
});
});
});

View File

@ -18,38 +18,187 @@
*/
import { createMultiFormatter } from '@superset-ui/core';
import { TimeLocaleDefinition } from 'd3-time-format';
describe('createMultiFormatter()', () => {
describe('creates a multi-step formatter', () => {
const formatter = createMultiFormatter({
id: 'my_format',
useLocalTime: true,
describe('when locale is undefined', () => {
describe('and use local time is false', () => {
const formatter = createMultiFormatter({
id: 'my_format',
useLocalTime: false,
});
it('formats millisecond', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33, 100))).toEqual(
'.100',
);
});
it('formats second', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33))).toEqual(':33');
});
it('format minutes', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22))).toEqual('04:22');
});
it('format hours', () => {
expect(formatter(new Date('2018-11-18 11:00 UTC'))).toEqual('11 AM');
});
it('format first day of week', () => {
expect(formatter(new Date('2018-11-18 UTC'))).toEqual('Nov 18');
});
it('format other day of week', () => {
expect(formatter(new Date('2018-11-20 UTC'))).toEqual('Tue 20');
});
it('format month', () => {
expect(formatter(new Date('2018-11-1 UTC'))).toEqual('November');
});
it('format year', () => {
expect(formatter(new Date('2018-1-1 UTC'))).toEqual('2018');
});
});
describe('and use local time is true', () => {
const formatter = createMultiFormatter({
id: 'my_format',
useLocalTime: true,
});
it('formats millisecond', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33, 100))).toEqual(
'.100',
);
});
it('formats second', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33))).toEqual(':33');
});
it('format minutes', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22))).toEqual('11:22');
});
it('format hours', () => {
expect(formatter(new Date(2018, 10, 20, 11))).toEqual('11 AM');
});
it('format first day of week', () => {
expect(formatter(new Date(2018, 10, 18))).toEqual('Nov 18');
});
it('format other day of week', () => {
expect(formatter(new Date(2018, 10, 20))).toEqual('Tue 20');
});
it('format month', () => {
expect(formatter(new Date(2018, 10))).toEqual('November');
});
it('format year', () => {
expect(formatter(new Date(2018, 0))).toEqual('2018');
});
});
});
it('formats millisecond', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33, 100))).toEqual(
'.100',
);
});
describe('when locale is not default', () => {
const locale: TimeLocaleDefinition = {
dateTime: '%A, %e de %B de %Y. %X',
date: '%d/%m/%Y',
time: '%H:%M:%S',
periods: ['AM', 'PM'],
days: [
'Domingo',
'Segunda',
'Terça',
'Quarta',
'Quinta',
'Sexta',
'Sábado',
],
shortDays: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
months: [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
],
shortMonths: [
'Jan',
'Fev',
'Mar',
'Abr',
'Mai',
'Jun',
'Jul',
'Ago',
'Set',
'Out',
'Nov',
'Dez',
],
};
describe('and use local time is false', () => {
const formatter = createMultiFormatter({
id: 'my_format',
useLocalTime: false,
locale,
});
it('formats millisecond', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33, 100))).toEqual(
'.100',
);
});
it('formats second', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33))).toEqual(':33');
});
it('format minutes', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22))).toEqual('04:22');
});
it('format hours', () => {
expect(formatter(new Date('2018-11-18 11:00 UTC'))).toEqual('11 AM');
});
it('format first day of week', () => {
expect(formatter(new Date('2018-11-18 UTC'))).toEqual('Nov 18');
});
it('format other day of week', () => {
expect(formatter(new Date('2018-11-20 UTC'))).toEqual('Ter 20');
});
it('format month', () => {
expect(formatter(new Date('2018-11-1 UTC'))).toEqual('Novembro');
});
it('format year', () => {
expect(formatter(new Date('2018-1-1 UTC'))).toEqual('2018');
});
});
it('formats second', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33))).toEqual(':33');
});
it('format minutes', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22))).toEqual('11:22');
});
it('format hours', () => {
expect(formatter(new Date(2018, 10, 20, 11))).toEqual('11 AM');
});
it('format first day of week', () => {
expect(formatter(new Date(2018, 10, 18))).toEqual('Nov 18');
});
it('format other day of week', () => {
expect(formatter(new Date(2018, 10, 20))).toEqual('Tue 20');
});
it('format month', () => {
expect(formatter(new Date(2018, 10))).toEqual('November');
});
it('format year', () => {
expect(formatter(new Date(2018, 0))).toEqual('2018');
describe('and use local time is true', () => {
const formatter = createMultiFormatter({
id: 'my_format',
useLocalTime: true,
locale,
});
it('formats millisecond', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33, 100))).toEqual(
'.100',
);
});
it('formats second', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22, 33))).toEqual(':33');
});
it('format minutes', () => {
expect(formatter(new Date(2018, 10, 20, 11, 22))).toEqual('11:22');
});
it('format hours', () => {
expect(formatter(new Date(2018, 10, 20, 11))).toEqual('11 AM');
});
it('format first day of week', () => {
expect(formatter(new Date(2018, 10, 18))).toEqual('Nov 18');
});
it('format other day of week', () => {
expect(formatter(new Date(2018, 10, 20))).toEqual('Ter 20');
});
it('format month', () => {
expect(formatter(new Date(2018, 10))).toEqual('Novembro');
});
it('format year', () => {
expect(formatter(new Date(2018, 0))).toEqual('2018');
});
});
});
});

View File

@ -17,26 +17,98 @@
* under the License.
*/
import { TimeFormatter, smartDateFormatter } from '@superset-ui/core';
import { TimeLocaleDefinition } from 'd3-time-format';
import { TimeFormatter, createSmartDateFormatter } from '@superset-ui/core';
describe('smartDateFormatter', () => {
it('is a function', () => {
expect(smartDateFormatter).toBeInstanceOf(TimeFormatter);
describe('createSmartDateFormatter', () => {
describe('when locale is default', () => {
const smartDateFormatter = createSmartDateFormatter();
it('is a function', () => {
expect(smartDateFormatter).toBeInstanceOf(TimeFormatter);
});
it('shows only year when 1st day of the year', () => {
expect(smartDateFormatter(new Date('2020-01-01'))).toBe('2020');
});
it('shows only month when 1st of month', () => {
expect(smartDateFormatter(new Date('2020-03-01'))).toBe('March');
});
it('does not show day of week when it is Sunday', () => {
expect(smartDateFormatter(new Date('2020-03-15'))).toBe('Mar 15');
});
it('shows weekday when it is not Sunday (and no ms/sec/min/hr)', () => {
expect(smartDateFormatter(new Date('2020-03-03'))).toBe('Tue 03');
});
});
describe('when different locale is not default', () => {
const locale: TimeLocaleDefinition = {
dateTime: '%A, %e de %B de %Y. %X',
date: '%d/%m/%Y',
time: '%H:%M:%S',
periods: ['AM', 'PM'],
days: [
'Domingo',
'Segunda',
'Terça',
'Quarta',
'Quinta',
'Sexta',
'Sábado',
],
shortDays: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
months: [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
],
shortMonths: [
'Jan',
'Fev',
'Mar',
'Abr',
'Mai',
'Jun',
'Jul',
'Ago',
'Set',
'Out',
'Nov',
'Dez',
],
};
const smartDateFormatter = createSmartDateFormatter(locale);
it('shows only year when 1st day of the year', () => {
expect(smartDateFormatter(new Date('2020-01-01'))).toBe('2020');
});
it('is a function', () => {
expect(smartDateFormatter).toBeInstanceOf(TimeFormatter);
});
it('shows only month when 1st of month', () => {
expect(smartDateFormatter(new Date('2020-03-01'))).toBe('March');
});
it('shows only year when 1st day of the year', () => {
expect(smartDateFormatter(new Date('2020-01-01'))).toBe('2020');
});
it('does not show day of week when it is Sunday', () => {
expect(smartDateFormatter(new Date('2020-03-15'))).toBe('Mar 15');
});
it('shows only month when 1st of month', () => {
expect(smartDateFormatter(new Date('2020-03-01'))).toBe('Março');
});
it('shows weekday when it is not Sunday (and no ms/sec/min/hr)', () => {
expect(smartDateFormatter(new Date('2020-03-03'))).toBe('Tue 03');
it('does not show day of week when it is Sunday', () => {
expect(smartDateFormatter(new Date('2023-10-15'))).toBe('Out 15');
});
it('shows weekday when it is not Sunday (and no ms/sec/min/hr)', () => {
expect(smartDateFormatter(new Date('2020-03-03'))).toBe('Ter 03');
});
});
});

View File

@ -17,40 +17,125 @@
* under the License.
*/
import { TimeFormatter, smartDateDetailedFormatter } from '@superset-ui/core';
import { TimeLocaleDefinition } from 'd3-time-format';
import {
TimeFormatter,
createSmartDateDetailedFormatter,
} from '@superset-ui/core';
describe('smartDateDetailedFormatter', () => {
const formatter = smartDateDetailedFormatter;
describe('when locale is default', () => {
const formatter = createSmartDateDetailedFormatter();
it('is a function', () => {
expect(formatter).toBeInstanceOf(TimeFormatter);
it('is a function', () => {
expect(formatter).toBeInstanceOf(TimeFormatter);
});
it('shows only year when 1st day of the year', () => {
expect(formatter(new Date('2020-01-01T00:00:00.000+00:00'))).toBe('2020');
});
it('shows full date when a regular date', () => {
expect(formatter(new Date('2020-03-01T00:00:00.000+00:00'))).toBe(
'2020-03-01',
);
});
it('shows full date including time of day without seconds when hour precision', () => {
expect(formatter(new Date('2020-03-01T13:00:00.000+00:00'))).toBe(
'2020-03-01 13:00',
);
});
it('shows full date including time of day when minute precision', () => {
expect(formatter(new Date('2020-03-10T13:10:00.000+00:00'))).toBe(
'2020-03-10 13:10',
);
});
it('shows full date including time of day when subsecond precision', () => {
expect(formatter(new Date('2020-03-10T13:10:00.100+00:00'))).toBe(
'2020-03-10 13:10:00.100',
);
});
});
describe('when locale is specified', () => {
const locale: TimeLocaleDefinition = {
dateTime: '%A, %e de %B de %Y. %X',
date: '%d/%m/%Y',
time: '%H:%M:%S',
periods: ['AM', 'PM'],
days: [
'Domingo',
'Segunda',
'Terça',
'Quarta',
'Quinta',
'Sexta',
'Sábado',
],
shortDays: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
months: [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
],
shortMonths: [
'Jan',
'Fev',
'Mar',
'Abr',
'Mai',
'Jun',
'Jul',
'Ago',
'Set',
'Out',
'Nov',
'Dez',
],
};
const formatter = createSmartDateDetailedFormatter(locale);
it('shows only year when 1st day of the year', () => {
expect(formatter(new Date('2020-01-01T00:00:00.000+00:00'))).toBe('2020');
});
it('is a function', () => {
expect(formatter).toBeInstanceOf(TimeFormatter);
});
it('shows full date when a regular date', () => {
expect(formatter(new Date('2020-03-01T00:00:00.000+00:00'))).toBe(
'2020-03-01',
);
});
it('shows only year when 1st day of the year', () => {
expect(formatter(new Date('2020-01-01T00:00:00.000+00:00'))).toBe('2020');
});
it('shows full date including time of day without seconds when hour precision', () => {
expect(formatter(new Date('2020-03-01T13:00:00.000+00:00'))).toBe(
'2020-03-01 13:00',
);
});
it('shows full date when a regular date', () => {
expect(formatter(new Date('2020-03-01T00:00:00.000+00:00'))).toBe(
'2020-03-01',
);
});
it('shows full date including time of day when minute precision', () => {
expect(formatter(new Date('2020-03-10T13:10:00.000+00:00'))).toBe(
'2020-03-10 13:10',
);
});
it('shows full date including time of day without seconds when hour precision', () => {
expect(formatter(new Date('2020-03-01T13:00:00.000+00:00'))).toBe(
'2020-03-01 13:00',
);
});
it('shows full date including time of day when subsecond precision', () => {
expect(formatter(new Date('2020-03-10T13:10:00.100+00:00'))).toBe(
'2020-03-10 13:10:00.100',
);
it('shows full date including time of day when minute precision', () => {
expect(formatter(new Date('2020-03-10T13:10:00.000+00:00'))).toBe(
'2020-03-10 13:10',
);
});
it('shows full date including time of day when subsecond precision', () => {
expect(formatter(new Date('2020-03-10T13:10:00.100+00:00'))).toBe(
'2020-03-10 13:10:00.100',
);
});
});
});

View File

@ -17,25 +17,95 @@
* under the License.
*/
import { TimeFormatter, smartDateVerboseFormatter } from '@superset-ui/core';
import { TimeLocaleDefinition } from 'd3-time-format';
import {
TimeFormatter,
createSmartDateVerboseFormatter,
} from '@superset-ui/core';
describe('smartDateVerboseFormatter', () => {
const formatter = smartDateVerboseFormatter;
describe('when locale is default', () => {
const formatter = createSmartDateVerboseFormatter();
it('is a function', () => {
expect(formatter).toBeInstanceOf(TimeFormatter);
it('is a function', () => {
expect(formatter).toBeInstanceOf(TimeFormatter);
});
it('shows only year when 1st day of the year', () => {
expect(formatter(new Date('2020-01-01'))).toBe('2020');
});
it('shows month and year when 1st of month', () => {
expect(formatter(new Date('2020-03-01'))).toBe('Mar 2020');
});
it('shows weekday when any day of the month', () => {
expect(formatter(new Date('2020-03-03'))).toBe('Tue Mar 3');
expect(formatter(new Date('2020-03-15'))).toBe('Sun Mar 15');
});
});
describe('when locale is not default', () => {
const locale: TimeLocaleDefinition = {
dateTime: '%A, %e de %B de %Y. %X',
date: '%d/%m/%Y',
time: '%H:%M:%S',
periods: ['AM', 'PM'],
days: [
'Domingo',
'Segunda',
'Terça',
'Quarta',
'Quinta',
'Sexta',
'Sábado',
],
shortDays: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
months: [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
],
shortMonths: [
'Jan',
'Fev',
'Mar',
'Abr',
'Mai',
'Jun',
'Jul',
'Ago',
'Set',
'Out',
'Nov',
'Dez',
],
};
const formatter = createSmartDateVerboseFormatter(locale);
it('shows only year when 1st day of the year', () => {
expect(formatter(new Date('2020-01-01'))).toBe('2020');
});
it('is a function', () => {
expect(formatter).toBeInstanceOf(TimeFormatter);
});
it('shows month and year when 1st of month', () => {
expect(formatter(new Date('2020-03-01'))).toBe('Mar 2020');
});
it('shows only year when 1st day of the year', () => {
expect(formatter(new Date('2020-01-01'))).toBe('2020');
});
it('shows weekday when any day of the month', () => {
expect(formatter(new Date('2020-03-03'))).toBe('Tue Mar 3');
expect(formatter(new Date('2020-03-15'))).toBe('Sun Mar 15');
it('shows month and year when 1st of month', () => {
expect(formatter(new Date('2020-04-01'))).toBe('Abr 2020');
});
it('shows weekday when any day of the month', () => {
expect(formatter(new Date('2020-03-03'))).toBe('Ter Mar 3');
expect(formatter(new Date('2020-03-15'))).toBe('Dom Mar 15');
});
});
});

View File

@ -25,8 +25,12 @@ import {
getTimeFormatterRegistry,
LOCAL_PREFIX,
PREVIEW_TIME,
smartDateFormatter,
smartDateVerboseFormatter,
SMART_DATE_ID,
SMART_DATE_VERBOSE_ID,
SMART_DATE_DETAILED_ID,
createSmartDateFormatter,
createSmartDateVerboseFormatter,
createSmartDateDetailedFormatter,
TimeFormats,
TimeFormatter,
} from '@superset-ui/core';
@ -41,8 +45,12 @@ describe('index', () => {
getTimeFormatterRegistry,
LOCAL_PREFIX,
PREVIEW_TIME,
smartDateFormatter,
smartDateVerboseFormatter,
SMART_DATE_ID,
SMART_DATE_VERBOSE_ID,
SMART_DATE_DETAILED_ID,
createSmartDateFormatter,
createSmartDateVerboseFormatter,
createSmartDateDetailedFormatter,
TimeFormats,
TimeFormatter,
].forEach(x => expect(x).toBeDefined());

View File

@ -29,7 +29,7 @@ import {
getTimeFormatter,
isDefined,
NumberFormats,
smartDateVerboseFormatter,
SMART_DATE_VERBOSE_ID,
t,
} from '@superset-ui/core';
@ -82,6 +82,8 @@ const NO_DATA_RENDER_DATA = [
},
];
const smartDateVerboseFormatter = getTimeFormatter(SMART_DATE_VERBOSE_ID);
// Override the noData render function to make a prettier UX
// Code adapted from https://github.com/novus/nvd3/blob/master/src/utils.js#L653
nv.utils.noData = function noData(chart, container) {

View File

@ -19,7 +19,11 @@
import d3 from 'd3';
import d3tip from 'd3-tip';
import dompurify from 'dompurify';
import { smartDateFormatter, getNumberFormatter } from '@superset-ui/core';
import {
SMART_DATE_ID,
getTimeFormatter,
getNumberFormatter,
} from '@superset-ui/core';
// Regexp for the label added to time shifted series
// (1 hour offset, 2 days offset, etc.)
const TIME_SHIFT_PATTERN = /\d+ \w+ offset/;
@ -42,8 +46,8 @@ export function cleanColorInput(value) {
* @param {*} format
*/
export function getTimeOrNumberFormatter(format) {
return format === 'smart_date'
? smartDateFormatter
return format === SMART_DATE_ID
? getTimeFormatter(SMART_DATE_ID)
: getNumberFormatter(format);
}

View File

@ -16,6 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
import {
getTimeFormatterRegistry,
SMART_DATE_ID,
createSmartDateFormatter,
} from '@superset-ui/core';
import {
computeStackedYDomain,
computeYDomain,
@ -111,6 +117,13 @@ const DATA_WITH_DISABLED_SERIES = [
];
describe('nvd3/utils', () => {
beforeEach(() => {
getTimeFormatterRegistry().registerValue(
SMART_DATE_ID,
createSmartDateFormatter(),
);
});
describe('getTimeOrNumberFormatter(format)', () => {
it('is a function', () => {
expect(typeof getTimeOrNumberFormatter).toBe('function');

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { GenericDataType, smartDateFormatter, t } from '@superset-ui/core';
import { GenericDataType, SMART_DATE_ID, t } from '@superset-ui/core';
import {
ControlPanelConfig,
D3_FORMAT_DOCS,
@ -71,7 +71,7 @@ export default {
renderTrigger: true,
choices: D3_TIME_FORMAT_OPTIONS,
description: D3_FORMAT_DOCS,
default: smartDateFormatter.id,
default: SMART_DATE_ID,
},
},
],

View File

@ -20,7 +20,8 @@ import React, { MouseEvent } from 'react';
import {
t,
getNumberFormatter,
smartDateVerboseFormatter,
getTimeFormatter,
SMART_DATE_VERBOSE_ID,
computeMaxFontSize,
BRAND_COLOR,
styled,
@ -45,7 +46,7 @@ class BigNumberVis extends React.PureComponent<BigNumberVizProps> {
static defaultProps = {
className: '',
headerFormatter: defaultNumberFormatter,
formatTime: smartDateVerboseFormatter,
formatTime: getTimeFormatter(SMART_DATE_VERBOSE_ID),
headerFontSize: PROPORTION.HEADER,
kickerFontSize: PROPORTION.KICKER,
mainColor: BRAND_COLOR,

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { smartDateFormatter, t } from '@superset-ui/core';
import { SMART_DATE_ID, t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlSubSectionHeader,
@ -145,7 +145,7 @@ const config: ControlPanelConfig = {
renderTrigger: true,
choices: D3_TIME_FORMAT_OPTIONS,
description: D3_FORMAT_DOCS,
default: smartDateFormatter.id,
default: SMART_DATE_ID,
},
},
],

View File

@ -19,11 +19,12 @@
import {
extractTimegrain,
getNumberFormatter,
getTimeFormatter,
NumberFormats,
GenericDataType,
getMetricLabel,
t,
smartDateVerboseFormatter,
SMART_DATE_VERBOSE_ID,
TimeFormatter,
getXAxisLabel,
Metric,
@ -42,6 +43,8 @@ import { getDefaultTooltip } from '../../utils/tooltip';
import { Refs } from '../../types';
const defaultNumberFormatter = getNumberFormatter();
const smartDateVerboseFormatter = getTimeFormatter(SMART_DATE_VERBOSE_ID);
export function renderTooltipFactory(
formatDate: TimeFormatter = smartDateVerboseFormatter,
formatValue: ValueFormatter | TimeFormatter = defaultNumberFormatter,

View File

@ -21,7 +21,7 @@ import moment from 'moment';
import {
getTimeFormatter,
getTimeFormatterForGranularity,
smartDateFormatter,
SMART_DATE_ID,
TimeGranularity,
} from '@superset-ui/core';
@ -41,6 +41,6 @@ export const getDateFormatter = (
granularity?: TimeGranularity,
fallbackFormat?: string | null,
) =>
timeFormat === smartDateFormatter.id
timeFormat === SMART_DATE_ID
? getTimeFormatterForGranularity(granularity)
: getTimeFormatter(timeFormat ?? fallbackFormat);

View File

@ -25,12 +25,21 @@ import {
isSavedMetric,
NumberFormats,
QueryFormMetric,
smartDateDetailedFormatter,
smartDateFormatter,
SMART_DATE_DETAILED_ID,
SMART_DATE_ID,
SMART_DATE_VERBOSE_ID,
TimeFormatter,
ValueFormatter,
} from '@superset-ui/core';
export const getSmartDateDetailedFormatter = () =>
getTimeFormatter(SMART_DATE_DETAILED_ID);
export const getSmartDateFormatter = () => getTimeFormatter(SMART_DATE_ID);
export const getSmartDateVerboseFormatter = () =>
getTimeFormatter(SMART_DATE_VERBOSE_ID);
export const getPercentFormatter = (format?: string) =>
getNumberFormatter(
!format || format === NumberFormats.SMART_NUMBER
@ -68,8 +77,8 @@ export const getYAxisFormatter = (
export function getTooltipTimeFormatter(
format?: string,
): TimeFormatter | StringConstructor {
if (format === smartDateFormatter.id) {
return smartDateDetailedFormatter;
if (format === SMART_DATE_ID) {
return getSmartDateDetailedFormatter();
}
if (format) {
return getTimeFormatter(format);
@ -80,7 +89,7 @@ export function getTooltipTimeFormatter(
export function getXAxisFormatter(
format?: string,
): TimeFormatter | StringConstructor | undefined {
if (format === smartDateFormatter.id || !format) {
if (format === SMART_DATE_ID || !format) {
return undefined;
}
if (format) {

View File

@ -22,7 +22,7 @@ import {
isAdhocColumn,
isPhysicalColumn,
QueryFormMetric,
smartDateFormatter,
SMART_DATE_ID,
t,
validateNonEmpty,
} from '@superset-ui/core';
@ -299,7 +299,7 @@ const config: ControlPanelConfig = {
type: 'SelectControl',
freeForm: true,
label: t('Date format'),
default: smartDateFormatter.id,
default: SMART_DATE_ID,
renderTrigger: true,
choices: D3_TIME_FORMAT_OPTIONS,
description: t('D3 time format for datetime columns'),

View File

@ -24,7 +24,7 @@ import {
getTimeFormatter,
getTimeFormatterForGranularity,
QueryFormData,
smartDateFormatter,
SMART_DATE_ID,
TimeFormats,
} from '@superset-ui/core';
import { getColorFormatters } from '@superset-ui/chart-controls';
@ -120,7 +120,7 @@ export default function transformProps(chartProps: ChartProps<QueryFormData>) {
temporalColname: string,
) => {
let formatter: DateFormatter | undefined;
if (dateFormat === smartDateFormatter.id) {
if (dateFormat === SMART_DATE_ID) {
if (granularity) {
// time column use formats based on granularity
formatter = getTimeFormatterForGranularity(granularity);

View File

@ -26,7 +26,7 @@ import {
isPhysicalColumn,
QueryFormColumn,
QueryMode,
smartDateFormatter,
SMART_DATE_ID,
t,
} from '@superset-ui/core';
import {
@ -362,7 +362,7 @@ const config: ControlPanelConfig = {
type: 'SelectControl',
freeForm: true,
label: t('Timestamp format'),
default: smartDateFormatter.id,
default: SMART_DATE_ID,
renderTrigger: true,
clearable: false,
choices: D3_TIME_FORMAT_OPTIONS,

View File

@ -28,7 +28,7 @@ import {
getTimeFormatterForGranularity,
NumberFormats,
QueryMode,
smartDateFormatter,
SMART_DATE_ID,
TimeFormats,
TimeFormatter,
} from '@superset-ui/core';
@ -140,7 +140,7 @@ const processColumns = memoizeOne(function processColumns(
const customFormat = config.d3TimeFormat || savedFormat;
const timeFormat = customFormat || tableTimestampFormat;
// When format is "Adaptive Formatting" (smart_date)
if (timeFormat === smartDateFormatter.id) {
if (timeFormat === SMART_DATE_ID) {
if (granularity) {
// time column use formats based on granularity
formatter = getTimeFormatterForGranularity(granularity);

View File

@ -16,7 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t, DEFAULT_D3_FORMAT } from '@superset-ui/core';
import {
t,
DEFAULT_D3_FORMAT,
DEFAULT_D3_TIME_FORMAT,
} from '@superset-ui/core';
import { BootstrapData, CommonBootstrapData } from './types/bootstrapTypes';
@ -184,6 +188,7 @@ export const DEFAULT_COMMON_BOOTSTRAP_DATA: CommonBootstrapData = {
},
},
d3_format: DEFAULT_D3_FORMAT,
d3_time_format: DEFAULT_D3_TIME_FORMAT,
};
export const DEFAULT_BOOTSTRAP_DATA: BootstrapData = {

View File

@ -61,7 +61,10 @@ setupColors(
);
// Setup number formatters
setupFormatters(bootstrapData.common.d3_format);
setupFormatters(
bootstrapData.common.d3_format,
bootstrapData.common.d3_time_format,
);
setupDashboardComponents();

View File

@ -22,16 +22,22 @@ import {
getNumberFormatterRegistry,
NumberFormats,
getTimeFormatterRegistry,
smartDateFormatter,
smartDateVerboseFormatter,
SMART_DATE_ID,
SMART_DATE_DETAILED_ID,
SMART_DATE_VERBOSE_ID,
createSmartDateFormatter,
createSmartDateVerboseFormatter,
createSmartDateDetailedFormatter,
} from '@superset-ui/core';
import { FormatLocaleDefinition } from 'd3-format';
import { TimeLocaleDefinition } from 'd3-time-format';
export default function setupFormatters(
d3Format: Partial<FormatLocaleDefinition>,
d3NumberFormat: Partial<FormatLocaleDefinition>,
d3TimeFormat: Partial<TimeLocaleDefinition>,
) {
getNumberFormatterRegistry()
.setD3Format(d3Format)
.setD3Format(d3NumberFormat)
// Add shims for format strings that are deprecated or common typos.
// Temporary solution until performing a db migration to fix this.
.registerValue(',0', getNumberFormatter(',.4~f'))
@ -72,8 +78,21 @@ export default function setupFormatters(
createDurationFormatter({ formatSubMilliseconds: true }),
);
getTimeFormatterRegistry()
.registerValue('smart_date', smartDateFormatter)
.registerValue('smart_date_verbose', smartDateVerboseFormatter)
.setDefaultKey('smart_date');
const timeFormatterRegistry = getTimeFormatterRegistry();
timeFormatterRegistry
.setD3Format(d3TimeFormat)
.registerValue(
SMART_DATE_ID,
createSmartDateFormatter(timeFormatterRegistry.d3Format),
)
.registerValue(
SMART_DATE_VERBOSE_ID,
createSmartDateVerboseFormatter(timeFormatterRegistry.d3Format),
)
.registerValue(
SMART_DATE_DETAILED_ID,
createSmartDateDetailedFormatter(timeFormatterRegistry.d3Format),
)
.setDefaultKey(SMART_DATE_ID);
}

View File

@ -7,6 +7,7 @@ import {
SequentialSchemeConfig,
} from '@superset-ui/core';
import { FormatLocaleDefinition } from 'd3-format';
import { TimeLocaleDefinition } from 'd3-time-format';
import { isPlainObject } from 'lodash';
import { Languages } from 'src/features/home/LanguagePicker';
import { FlashMessage } from '../components/FlashProvider';
@ -152,6 +153,7 @@ export interface CommonBootstrapData {
theme_overrides: JsonObject;
menu_data: MenuData;
d3_format: Partial<FormatLocaleDefinition>;
d3_time_format: Partial<TimeLocaleDefinition>;
}
export interface BootstrapData {

View File

@ -398,6 +398,38 @@ class D3Format(TypedDict, total=False):
D3_FORMAT: D3Format = {}
# Override the default d3 locale for time format
# Default values are equivalent to
# D3_TIME_FORMAT = {
# "dateTime": "%x, %X",
# "date": "%-m/%-d/%Y",
# "time": "%-I:%M:%S %p",
# "periods": ["AM", "PM"],
# "days": ["Sunday", "Monday", "Tuesday", "Wednesday",
# "Thursday", "Friday", "Saturday"],
# "shortDays": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
# "months": ["January", "February", "March", "April",
# "May", "June", "July", "August",
# "September", "October", "November", "December"],
# "shortMonths": ["Jan", "Feb", "Mar", "Apr",
# "May", "Jun", "Jul", "Aug",
# "Sep", "Oct", "Nov", "Dec"]
# }
# https://github.com/d3/d3-time-format/tree/main#locales
class D3TimeFormat(TypedDict, total=False):
date: str
dateTime: str
time: str
periods: list[str]
days: list[str]
shortDays: list[str]
months: list[str]
shortMonths: list[str]
D3_TIME_FORMAT: D3TimeFormat = {}
CURRENCIES = ["USD", "EUR", "GBP", "INR", "MXN", "JPY", "CNY"]
# ---------------------------------------------------

View File

@ -415,6 +415,7 @@ def cached_common_bootstrap_data( # pylint: disable=unused-argument
"locale": language,
"language_pack": get_language_pack(language),
"d3_format": conf.get("D3_FORMAT"),
"d3_time_format": conf.get("D3_TIME_FORMAT"),
"currencies": conf.get("CURRENCIES"),
"feature_flags": get_feature_flags(),
"extra_sequential_color_schemes": conf["EXTRA_SEQUENTIAL_COLOR_SCHEMES"],