mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
[sqllab] add support for Jinja templating (#1426)
* [sqllab] add support for Jinja templating * Adressing comments * Presto macros * Progress * Addressing coments
This commit is contained in:
committed by
GitHub
parent
8c5e495272
commit
5944643da6
57
docs/sqllab.rst
Normal file
57
docs/sqllab.rst
Normal file
@@ -0,0 +1,57 @@
|
||||
SQL Lab
|
||||
=======
|
||||
|
||||
SQL Lab is a modern, feature-rich SQL IDE written in
|
||||
`React <https://facebook.github.io/react/>`_.
|
||||
|
||||
|
||||
Feature Overview
|
||||
----------------
|
||||
- Connects to just about any database backend
|
||||
- A multi-tab environment to work on multiple queries at a time
|
||||
- A smooth flow to visualize your query results using Caravel's rich
|
||||
visualization capabilities
|
||||
- Browse database metadata: tables, columns, indexes, partitions
|
||||
- Support for long-running queries
|
||||
- uses the `Celery distributed queue <http://www.python.org/>`_
|
||||
to dispatch query handling to workers
|
||||
- supports defining a "results backend" to persist query results
|
||||
- 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
|
||||
|
||||
|
||||
Templating with Jinja
|
||||
---------------------
|
||||
|
||||
.. code-block:: sql
|
||||
|
||||
SELECT *
|
||||
FROM some_table
|
||||
WHERE partition_key = '{{ preto.latest_partition('some_table') }}'
|
||||
|
||||
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
|
||||
Caravel's Jinja context:
|
||||
- ``time``: ``time``
|
||||
- ``datetime``: ``datetime.datetime``
|
||||
- ``uuid``: ``uuid``
|
||||
- ``random``: ``random``
|
||||
- ``relativedelta``: ``dateutil.relativedelta.relativedelta``
|
||||
- more to come!
|
||||
|
||||
`Jinja's builtin filters <http://jinja.pocoo.org/docs/dev/templates/>`_ can be also be applied where needed.
|
||||
|
||||
|
||||
.. autoclass:: caravel.jinja_context.PrestoContext
|
||||
:members:
|
||||
Reference in New Issue
Block a user