2016-10-26 14:09:27 -04:00
SQL Lab
=======
SQL Lab is a modern, feature-rich SQL IDE written in
`React <https://facebook.github.io/react/> `_ .
2018-04-13 13:23:27 -04:00
------
.. image :: images/screenshots/sqllab.png
------
2016-10-26 14:09:27 -04:00
Feature Overview
----------------
- Connects to just about any database backend
- A multi-tab environment to work on multiple queries at a time
2016-11-10 02:08:22 -05:00
- A smooth flow to visualize your query results using Superset's rich
2016-10-26 14:09:27 -04:00
visualization capabilities
- Browse database metadata: tables, columns, indexes, partitions
- Support for long-running queries
2017-06-01 00:26:17 -04:00
2016-10-26 14:09:27 -04:00
- uses the `Celery distributed queue <http://www.python.org/> `_
to dispatch query handling to workers
- supports defining a "results backend" to persist query results
2017-06-01 00:26:17 -04:00
2016-10-26 14:09:27 -04:00
- A search engine to find queries executed in the past
- Supports templating using the
`Jinja templating language <http://jinja.pocoo.org/docs/dev/> `_
which allows for using macros in your SQL code
2016-11-09 11:42:13 -05:00
Extra features
--------------
- Hit `` alt + enter `` as a keyboard shortcut to run your query
2016-10-26 14:09:27 -04:00
Templating with Jinja
---------------------
.. code-block :: sql
SELECT *
FROM some_table
2016-10-26 23:44:03 -04:00
WHERE partition_key = '{{ presto.latest_partition('some_table') }}'
2016-10-26 14:09:27 -04:00
Templating unleashes the power and capabilities of a
programming language within your SQL code.
Templates can also be used to write generic queries that are
parameterized so they can be re-used easily.
Available macros
''''''''''''''''
We expose certain modules from Python's standard library in
2016-11-10 02:08:22 -05:00
Superset's Jinja context:
2017-12-19 18:55:58 -05:00
2016-10-26 14:09:27 -04:00
- `` time `` : `` time ``
- `` datetime `` : `` datetime.datetime ``
- `` uuid `` : `` uuid ``
- `` random `` : `` random ``
- `` relativedelta `` : `` dateutil.relativedelta.relativedelta ``
`Jinja's builtin filters <http://jinja.pocoo.org/docs/dev/templates/> `_ can be also be applied where needed.
2016-11-10 02:08:22 -05:00
.. autoclass :: superset.jinja_context.PrestoTemplateProcessor
2016-10-26 14:09:27 -04:00
:members:
2017-04-05 13:45:32 -04:00
.. autofunction :: superset.jinja_context.url_param
2017-12-19 18:55:58 -05:00
2018-09-17 12:36:47 -04:00
.. autofunction :: superset.jinja_context.filter_values
2017-12-19 18:55:58 -05:00
Extending macros
''''''''''''''''
2017-12-26 02:39:28 -05:00
As mentioned in the `Installation & Configuration <https://superset.incubator.apache.org/installation.html#installation-configuration> `_ documentation,
2017-12-19 18:55:58 -05:00
it's possible for administrators to expose more more macros in their
environment using the configuration variable `` JINJA_CONTEXT_ADDONS `` .
All objects referenced in this dictionary will become available for users
to integrate in their queries in **SQL Lab** .