2019-01-22 11:21:13 -05:00
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
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
2018-12-01 12:34:49 -05:00
- uses the `Celery distributed queue <http://www.celeryproject.org/> `_
2016-10-26 14:09:27 -04:00
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.
2019-07-03 12:54:03 -04:00
.. autofunction :: superset.jinja_context.current_user_id
.. autofunction :: superset.jinja_context.current_username
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
2019-07-20 12:12:35 -04:00
.. autofunction :: superset.jinja_context.CacheKeyWrapper.cache_key_wrapper
2019-07-03 12:54:03 -04:00
.. autoclass :: superset.jinja_context.PrestoTemplateProcessor
:members:
.. autoclass :: superset.jinja_context.HiveTemplateProcessor
:members:
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** .