Latest docs

This commit is contained in:
Maxime Beauchemin
2017-05-04 22:58:39 -07:00
parent edc8d64f60
commit 7f66807a57
16 changed files with 373 additions and 97 deletions

BIN
_images/s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,9 +1,12 @@
.. image:: _static/img/s.png
Superset's documentation
''''''''''''''''''''''''
Superset is a data exploration platform designed to be visual, intuitive
and interactive.
----------------
.. warning:: This project was originally named Panoramix, was renamed to

View File

@@ -4,8 +4,9 @@ Installation & Configuration
Getting Started
---------------
Superset is tested using Python 2.7 and Python 3.4+. Python 3 is the recommended version,
Python 2.6 won't be supported.
Superset is tested against Python ``2.7`` and Python ``3.4``.
Airbnb currently uses 2.7.* in production. We do not plan on supporting
Python ``2.6``.
OS dependencies
@@ -30,12 +31,12 @@ For **Fedora** and **RHEL-derivatives**, the following command will ensure
that the required dependencies are installed: ::
sudo yum upgrade python-setuptools
sudo yum install gcc libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel
sudo yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel
**OSX**, system python is not recommended. brew's python also ships with pip ::
brew install pkg-config libffi openssl python
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography==1.7.2
**Windows** isn't officially supported at this point, but if you want to
attempt it, download `get-pip.py <https://bootstrap.pypa.io/get-pip.py>`_, and run ``python get-pip.py`` which may need admin access. Then run the following: ::
@@ -195,7 +196,7 @@ Here's a list of some of the recommended packages.
+---------------+-------------------------------------+-------------------------------------------------+
| sqlite | | ``sqlite://`` |
+---------------+-------------------------------------+-------------------------------------------------+
| Redshift | ``pip install sqlalchemy-redshift`` | ``redshift+psycopg2://`` |
| Redshift | ``pip install sqlalchemy-redshift`` | ``postgresql+psycopg2://`` |
+---------------+-------------------------------------+-------------------------------------------------+
| MSSQL | ``pip install pymssql`` | ``mssql://`` |
+---------------+-------------------------------------+-------------------------------------------------+
@@ -205,12 +206,35 @@ Here's a list of some of the recommended packages.
+---------------+-------------------------------------+-------------------------------------------------+
| Greenplum | ``pip install psycopg2`` | ``postgresql+psycopg2://`` |
+---------------+-------------------------------------+-------------------------------------------------+
| Athena | ``pip install "PyAthenaJDBC>1.0.9"``| ``awsathena+jdbc://`` |
+---------------+-------------------------------------+-------------------------------------------------+
| Vertica | ``pip install | ``vertica+vertica_python://`` |
| | sqlalchemy-vertica-python`` | |
+---------------+-------------------------------------+-------------------------------------------------+
| ClickHouse | ``pip install | ``clickhouse://`` |
| | sqlalchemy-clickhouse`` | |
+---------------+-------------------------------------+-------------------------------------------------+
Note that many other database are supported, the main criteria being the
existence of a functional SqlAlchemy dialect and Python driver. Googling
the keyword ``sqlalchemy`` in addition of a keyword that describes the
database you want to connect to should get you to the right place.
(AWS) Athena
------------
This currently relies on an unreleased future version of `PyAthenaJDBC <https://github.com/laughingman7743/PyAthenaJDBC>`_. If you're adventurous or simply impatient, you can install directly from git: ::
pip install git+https://github.com/laughingman7743/PyAthenaJDBC@support_sqlalchemy
The connection string for Athena looks like this ::
awsathena+jdbc://{aws_access_key_id}:{aws_secret_access_key}@athena.{region_name}.amazonaws.com/{schema_name}?s3_staging_dir={s3_staging_dir}&...
Where you need to escape/encode at least the s3_staging_dir, i.e., ::
s3://... -> s3%3A//...
Caching
-------
@@ -222,9 +246,11 @@ complies with the Flask-Cache specifications.
Flask-Cache supports multiple caching backends (Redis, Memcached,
SimpleCache (in-memory), or the local filesystem). If you are going to use
Memcached please use the pylibmc client library as python-memcached does
Memcached please use the `pylibmc` client library as `python-memcached` does
not handle storing binary data correctly. If you use Redis, please install
`python-redis <https://pypi.python.org/pypi/redis>`.
the `redis <https://pypi.python.org/pypi/redis>`_ Python package: ::
pip install redis
For setting your timeouts, this is done in the Superset metadata and goes
up the "timeout searchpath", from your slice configuration, to your
@@ -340,28 +366,74 @@ Upgrading should be as straightforward as running::
SQL Lab
-------
SQL Lab is a powerful SQL IDE that works with all SQLAlchemy compatible
databases out there. By default, queries are run in a web request, and
databases. By default, queries are executed in the scope of a web
request so they
may eventually timeout as queries exceed the maximum duration of a web
request in your environment, whether it'd be a reverse proxy or the Superset
server itself.
In the modern analytics world, it's not uncommon to run large queries that
run for minutes or hours.
On large analytic databases, it's common to run queries that
execute for minutes or hours.
To enable support for long running queries that
execute beyond the typical web request's timeout (30-60 seconds), it is
necessary to deploy an asynchronous backend, which consist of one or many
Superset worker, which is implemented as a Celery worker, and a Celery
broker for which we recommend using Redis or RabbitMQ.
necessary to configure an asynchronous backend for Superset which consist of:
It's also preferable to setup an async result backend as a key value store
that can hold the long-running query results for a period of time. More
details to come as to how to set this up here soon.
* one or many Superset worker (which is implemented as a Celery worker), and
can be started with the ``superset worker`` command, run
``superset worker --help`` to view the related options
* a celery broker (message queue) for which we recommend using Redis
or RabbitMQ
* a results backend that defines where the worker will persist the query
results
SQL Lab supports templating in queries, and it's possible to override
Configuring Celery requires defining a ``CELERY_CONFIG`` in your
``superset_config.py``. Both the worker and web server processes should
have the same configuration.
.. code-block:: python
class CeleryConfig(object):
BROKER_URL = 'redis://localhost:6379/0'
CELERY_IMPORTS = ('superset.sql_lab', )
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}}
CELERY_CONFIG = CeleryConfig
To setup a result backend, you need to pass an instance of a derivative
of ``werkzeug.contrib.cache.BaseCache`` to the ``RESULTS_BACKEND``
configuration key in your ``superset_config.py``. It's possible to use
Memcached, Redis, S3 (https://pypi.python.org/pypi/s3werkzeugcache),
memory or the file system (in a single server-type setup or for testing),
or to write your own caching interface. Your ``superset_config.py`` may
look something like:
.. code-block:: python
# On S3
from s3cache.s3cache import S3Cache
S3_CACHE_BUCKET = 'foobar-superset'
S3_CACHE_KEY_PREFIX = 'sql_lab_result'
RESULTS_BACKEND = S3Cache(S3_CACHE_BUCKET, S3_CACHE_KEY_PREFIX)
# On Redis
from werkzeug.contrib.cache import RedisCache
RESULTS_BACKEND = RedisCache(
host='localhost', port=6379, key_prefix='superset_results')
Also note that SQL Lab supports Jinja templating in queries, and that it's
possible to overload
the default Jinja context in your environment by defining the
``JINJA_CONTEXT_ADDONS`` in your superset configuration. Objects referenced
in this dictionary are made available for users to use in their SQL.
.. code-block:: python
JINJA_CONTEXT_ADDONS = {
'my_crazy_macro': lambda x: x*2,
}
Making your own build
---------------------
@@ -376,3 +448,28 @@ your environment.::
npm run build
cd $SUPERSET_HOME
python setup.py install
Blueprints
----------
`Blueprints are Flask's reusable apps <http://flask.pocoo.org/docs/0.12/blueprints/>`_.
Superset allows you to specify an array of Blueprints
an array of Blueprints in your ``superset_config`` module. Here's
an example on how this can work with a simple Blueprint. By doing
so, you can expect Superset to serve a page that says "OK"
at the ``/simple_page`` url. This can allow you to run other things such
as custom data visualization applications alongside Superset, on the
same server.
..code ::
from flask import Blueprint
simple_page = Blueprint('simple_page', __name__,
template_folder='templates')
@simple_page.route('/', defaults={'page': 'index'})
@simple_page.route('/<page>')
def show(page):
return "Ok"
BLUEPRINTS = [simple_page]

View File

@@ -50,6 +50,17 @@ The ``sql_lab`` role grants access to SQL Lab. Note that while ``Admin``
users have access to all databases by default, both ``Alpha`` and ``Gamma``
users need to be given access on a per database basis.
Public
""""""
It's possible to allow logged out users to access some Superset features.
By setting ``PUBLIC_ROLE_LIKE_GAMMA = True`` in your ``superset_config.py``,
you grant public role the same set of permissions as for the GAMMA role.
This is useful if one wants to enable anonymous users to view
dashboards. Explicit grant on specific datasets is still required, meaning
that you need to edit the ``Public`` role and add the Public data sources
to the role manually.
Managing Gamma per data source access
-------------------------------------

View File

@@ -58,3 +58,5 @@ Superset's Jinja context:
.. autoclass:: superset.jinja_context.PrestoTemplateProcessor
:members:
.. autofunction:: superset.jinja_context.url_param

BIN
_static/img/s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 162 KiB

View File

@@ -118,7 +118,7 @@
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li></li>
<li>Index</li>
<li class="wy-breadcrumbs-aside">
@@ -134,26 +134,10 @@
<h1 id="index">Index</h1>
<div class="genindex-jumpbox">
<a href="#L"><strong>L</strong></a>
| <a href="#P"><strong>P</strong></a>
<a href="#P"><strong>P</strong></a>
| <a href="#U"><strong>U</strong></a>
</div>
<h2 id="L">L</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="sqllab.html#superset.jinja_context.PrestoTemplateProcessor.latest_partition">latest_partition() (superset.jinja_context.PrestoTemplateProcessor method)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="sqllab.html#superset.jinja_context.PrestoTemplateProcessor.latest_sub_partition">latest_sub_partition() (superset.jinja_context.PrestoTemplateProcessor method)</a>
</dt>
</dl></td>
</tr></table>
<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
@@ -161,6 +145,16 @@
<dt><a href="sqllab.html#superset.jinja_context.PrestoTemplateProcessor">PrestoTemplateProcessor (class in superset.jinja_context)</a>
</dt>
</dl></td>
</tr></table>
<h2 id="U">U</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="sqllab.html#superset.jinja_context.url_param">url_param() (in module superset.jinja_context)</a>
</dt>
</dl></td>
</tr></table>

View File

@@ -130,7 +130,8 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="superset-s-documentation">
<img alt="_images/s.png" src="_images/s.png" />
<div class="section" id="superset-s-documentation">
<h1>Superset&#8217;s documentation<a class="headerlink" href="#superset-s-documentation" title="Permalink to this headline"></a></h1>
<p>Superset is a data exploration platform designed to be visual, intuitive
and interactive.</p>
@@ -181,6 +182,7 @@ to the user</li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#configuration-behind-a-load-balancer">Configuration behind a load balancer</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#configuration">Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#database-dependencies">Database dependencies</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#aws-athena">(AWS) Athena</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#caching">Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#deeper-sqlalchemy-integration">Deeper SQLAlchemy integration</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#schemas-postgres-redshift">Schemas (Postgres &amp; Redshift)</a></li>
@@ -191,6 +193,7 @@ to the user</li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#upgrading">Upgrading</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#sql-lab">SQL Lab</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#making-your-own-build">Making your own build</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#blueprints">Blueprints</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="tutorial.html">Tutorial for Superset Administrators</a><ul>

View File

@@ -90,6 +90,7 @@
<li class="toctree-l2"><a class="reference internal" href="#configuration-behind-a-load-balancer">Configuration behind a load balancer</a></li>
<li class="toctree-l2"><a class="reference internal" href="#configuration">Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="#database-dependencies">Database dependencies</a></li>
<li class="toctree-l2"><a class="reference internal" href="#aws-athena">(AWS) Athena</a></li>
<li class="toctree-l2"><a class="reference internal" href="#caching">Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="#deeper-sqlalchemy-integration">Deeper SQLAlchemy integration</a></li>
<li class="toctree-l2"><a class="reference internal" href="#schemas-postgres-redshift">Schemas (Postgres &amp; Redshift)</a></li>
@@ -100,6 +101,7 @@
<li class="toctree-l2"><a class="reference internal" href="#upgrading">Upgrading</a></li>
<li class="toctree-l2"><a class="reference internal" href="#sql-lab">SQL Lab</a></li>
<li class="toctree-l2"><a class="reference internal" href="#making-your-own-build">Making your own build</a></li>
<li class="toctree-l2"><a class="reference internal" href="#blueprints">Blueprints</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="tutorial.html">Tutorial for Superset Administrators</a></li>
@@ -155,8 +157,9 @@
<h1>Installation &amp; Configuration<a class="headerlink" href="#installation-configuration" title="Permalink to this headline"></a></h1>
<div class="section" id="getting-started">
<h2>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline"></a></h2>
<p>Superset is tested using Python 2.7 and Python 3.4+. Python 3 is the recommended version,
Python 2.6 won&#8217;t be supported.</p>
<p>Superset is tested against Python <code class="docutils literal"><span class="pre">2.7</span></code> and Python <code class="docutils literal"><span class="pre">3.4</span></code>.
Airbnb currently uses 2.7.* in production. We do not plan on supporting
Python <code class="docutils literal"><span class="pre">2.6</span></code>.</p>
</div>
<div class="section" id="os-dependencies">
<h2>OS dependencies<a class="headerlink" href="#os-dependencies" title="Permalink to this headline"></a></h2>
@@ -175,12 +178,12 @@ the required dependencies are installed:</p>
<p>For <strong>Fedora</strong> and <strong>RHEL-derivatives</strong>, the following command will ensure
that the required dependencies are installed:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">yum</span> <span class="n">upgrade</span> <span class="n">python</span><span class="o">-</span><span class="n">setuptools</span>
<span class="n">sudo</span> <span class="n">yum</span> <span class="n">install</span> <span class="n">gcc</span> <span class="n">libffi</span><span class="o">-</span><span class="n">devel</span> <span class="n">python</span><span class="o">-</span><span class="n">devel</span> <span class="n">python</span><span class="o">-</span><span class="n">pip</span> <span class="n">python</span><span class="o">-</span><span class="n">wheel</span> <span class="n">openssl</span><span class="o">-</span><span class="n">devel</span> <span class="n">libsasl2</span><span class="o">-</span><span class="n">devel</span> <span class="n">openldap</span><span class="o">-</span><span class="n">devel</span>
<span class="n">sudo</span> <span class="n">yum</span> <span class="n">install</span> <span class="n">gcc</span> <span class="n">gcc</span><span class="o">-</span><span class="n">c</span><span class="o">++</span> <span class="n">libffi</span><span class="o">-</span><span class="n">devel</span> <span class="n">python</span><span class="o">-</span><span class="n">devel</span> <span class="n">python</span><span class="o">-</span><span class="n">pip</span> <span class="n">python</span><span class="o">-</span><span class="n">wheel</span> <span class="n">openssl</span><span class="o">-</span><span class="n">devel</span> <span class="n">libsasl2</span><span class="o">-</span><span class="n">devel</span> <span class="n">openldap</span><span class="o">-</span><span class="n">devel</span>
</pre></div>
</div>
<p><strong>OSX</strong>, system python is not recommended. brew&#8217;s python also ships with pip</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">brew</span> <span class="n">install</span> <span class="n">pkg</span><span class="o">-</span><span class="n">config</span> <span class="n">libffi</span> <span class="n">openssl</span> <span class="n">python</span>
<span class="n">env</span> <span class="n">LDFLAGS</span><span class="o">=</span><span class="s2">&quot;-L$(brew --prefix openssl)/lib&quot;</span> <span class="n">CFLAGS</span><span class="o">=</span><span class="s2">&quot;-I$(brew --prefix openssl)/include&quot;</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">cryptography</span>
<span class="n">env</span> <span class="n">LDFLAGS</span><span class="o">=</span><span class="s2">&quot;-L$(brew --prefix openssl)/lib&quot;</span> <span class="n">CFLAGS</span><span class="o">=</span><span class="s2">&quot;-I$(brew --prefix openssl)/include&quot;</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">cryptography</span><span class="o">==</span><span class="mf">1.7</span><span class="o">.</span><span class="mi">2</span>
</pre></div>
</div>
<p><strong>Windows</strong> isn&#8217;t officially supported at this point, but if you want to
@@ -355,7 +358,7 @@ connect to the databases you want to access through Superset.</p>
</tr>
<tr class="row-odd"><td>Redshift</td>
<td><code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">sqlalchemy-redshift</span></code></td>
<td><code class="docutils literal"><span class="pre">redshift+psycopg2://</span></code></td>
<td><code class="docutils literal"><span class="pre">postgresql+psycopg2://</span></code></td>
</tr>
<tr class="row-even"><td>MSSQL</td>
<td><code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">pymssql</span></code></td>
@@ -373,6 +376,20 @@ connect to the databases you want to access through Superset.</p>
<td><code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">psycopg2</span></code></td>
<td><code class="docutils literal"><span class="pre">postgresql+psycopg2://</span></code></td>
</tr>
<tr class="row-even"><td>Athena</td>
<td><code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">&quot;PyAthenaJDBC&gt;1.0.9&quot;</span></code></td>
<td><code class="docutils literal"><span class="pre">awsathena+jdbc://</span></code></td>
</tr>
<tr class="row-odd"><td>Vertica</td>
<td><code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span>
<span class="pre">sqlalchemy-vertica-python</span></code></td>
<td><code class="docutils literal"><span class="pre">vertica+vertica_python://</span></code></td>
</tr>
<tr class="row-even"><td>ClickHouse</td>
<td><code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span>
<span class="pre">sqlalchemy-clickhouse</span></code></td>
<td><code class="docutils literal"><span class="pre">clickhouse://</span></code></td>
</tr>
</tbody>
</table>
<p>Note that many other database are supported, the main criteria being the
@@ -380,6 +397,21 @@ existence of a functional SqlAlchemy dialect and Python driver. Googling
the keyword <code class="docutils literal"><span class="pre">sqlalchemy</span></code> in addition of a keyword that describes the
database you want to connect to should get you to the right place.</p>
</div>
<div class="section" id="aws-athena">
<h2>(AWS) Athena<a class="headerlink" href="#aws-athena" title="Permalink to this headline"></a></h2>
<p>This currently relies on an unreleased future version of <a class="reference external" href="https://github.com/laughingman7743/PyAthenaJDBC">PyAthenaJDBC</a>. If you&#8217;re adventurous or simply impatient, you can install directly from git:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">git</span><span class="o">+</span><span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">laughingman7743</span><span class="o">/</span><span class="n">PyAthenaJDBC</span><span class="nd">@support_sqlalchemy</span>
</pre></div>
</div>
<p>The connection string for Athena looks like this</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>awsathena+jdbc://{aws_access_key_id}:{aws_secret_access_key}@athena.{region_name}.amazonaws.com/{schema_name}?s3_staging_dir={s3_staging_dir}&amp;...
</pre></div>
</div>
<p>Where you need to escape/encode at least the s3_staging_dir, i.e.,</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">s3</span><span class="p">:</span><span class="o">//...</span> <span class="o">-&gt;</span> <span class="n">s3</span><span class="o">%</span><span class="mi">3</span><span class="n">A</span><span class="o">//...</span>
</pre></div>
</div>
</div>
<div class="section" id="caching">
<h2>Caching<a class="headerlink" href="#caching" title="Permalink to this headline"></a></h2>
<p>Superset uses <a class="reference external" href="https://pythonhosted.org/Flask-Cache/">Flask-Cache</a> for
@@ -388,9 +420,12 @@ a <code class="docutils literal"><span class="pre">CACHE_CONFIG</span></code>, c
complies with the Flask-Cache specifications.</p>
<p>Flask-Cache supports multiple caching backends (Redis, Memcached,
SimpleCache (in-memory), or the local filesystem). If you are going to use
Memcached please use the pylibmc client library as python-memcached does
Memcached please use the <cite>pylibmc</cite> client library as <cite>python-memcached</cite> does
not handle storing binary data correctly. If you use Redis, please install
<cite>python-redis &lt;https://pypi.python.org/pypi/redis&gt;</cite>.</p>
the <a class="reference external" href="https://pypi.python.org/pypi/redis">redis</a> Python package:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">redis</span>
</pre></div>
</div>
<p>For setting your timeouts, this is done in the Superset metadata and goes
up the &#8220;timeout searchpath&#8221;, from your slice configuration, to your
data source&#8217;s configuration, to your database&#8217;s and ultimately falls back
@@ -487,24 +522,66 @@ environment variable:</p>
<div class="section" id="sql-lab">
<h2>SQL Lab<a class="headerlink" href="#sql-lab" title="Permalink to this headline"></a></h2>
<p>SQL Lab is a powerful SQL IDE that works with all SQLAlchemy compatible
databases out there. By default, queries are run in a web request, and
databases. By default, queries are executed in the scope of a web
request so they
may eventually timeout as queries exceed the maximum duration of a web
request in your environment, whether it&#8217;d be a reverse proxy or the Superset
server itself.</p>
<p>In the modern analytics world, it&#8217;s not uncommon to run large queries that
run for minutes or hours.
<p>On large analytic databases, it&#8217;s common to run queries that
execute for minutes or hours.
To enable support for long running queries that
execute beyond the typical web request&#8217;s timeout (30-60 seconds), it is
necessary to deploy an asynchronous backend, which consist of one or many
Superset worker, which is implemented as a Celery worker, and a Celery
broker for which we recommend using Redis or RabbitMQ.</p>
<p>It&#8217;s also preferable to setup an async result backend as a key value store
that can hold the long-running query results for a period of time. More
details to come as to how to set this up here soon.</p>
<p>SQL Lab supports templating in queries, and it&#8217;s possible to override
necessary to configure an asynchronous backend for Superset which consist of:</p>
<ul class="simple">
<li>one or many Superset worker (which is implemented as a Celery worker), and
can be started with the <code class="docutils literal"><span class="pre">superset</span> <span class="pre">worker</span></code> command, run
<code class="docutils literal"><span class="pre">superset</span> <span class="pre">worker</span> <span class="pre">--help</span></code> to view the related options</li>
<li>a celery broker (message queue) for which we recommend using Redis
or RabbitMQ</li>
<li>a results backend that defines where the worker will persist the query
results</li>
</ul>
<p>Configuring Celery requires defining a <code class="docutils literal"><span class="pre">CELERY_CONFIG</span></code> in your
<code class="docutils literal"><span class="pre">superset_config.py</span></code>. Both the worker and web server processes should
have the same configuration.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">CeleryConfig</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="n">BROKER_URL</span> <span class="o">=</span> <span class="s1">&#39;redis://localhost:6379/0&#39;</span>
<span class="n">CELERY_IMPORTS</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;superset.sql_lab&#39;</span><span class="p">,</span> <span class="p">)</span>
<span class="n">CELERY_RESULT_BACKEND</span> <span class="o">=</span> <span class="s1">&#39;redis://localhost:6379/0&#39;</span>
<span class="n">CELERY_ANNOTATIONS</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;tasks.add&#39;</span><span class="p">:</span> <span class="p">{</span><span class="s1">&#39;rate_limit&#39;</span><span class="p">:</span> <span class="s1">&#39;10/s&#39;</span><span class="p">}}</span>
<span class="n">CELERY_CONFIG</span> <span class="o">=</span> <span class="n">CeleryConfig</span>
</pre></div>
</div>
<p>To setup a result backend, you need to pass an instance of a derivative
of <code class="docutils literal"><span class="pre">werkzeug.contrib.cache.BaseCache</span></code> to the <code class="docutils literal"><span class="pre">RESULTS_BACKEND</span></code>
configuration key in your <code class="docutils literal"><span class="pre">superset_config.py</span></code>. It&#8217;s possible to use
Memcached, Redis, S3 (<a class="reference external" href="https://pypi.python.org/pypi/s3werkzeugcache">https://pypi.python.org/pypi/s3werkzeugcache</a>),
memory or the file system (in a single server-type setup or for testing),
or to write your own caching interface. Your <code class="docutils literal"><span class="pre">superset_config.py</span></code> may
look something like:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span> <span class="c1"># On S3</span>
<span class="kn">from</span> <span class="nn">s3cache.s3cache</span> <span class="kn">import</span> <span class="n">S3Cache</span>
<span class="n">S3_CACHE_BUCKET</span> <span class="o">=</span> <span class="s1">&#39;foobar-superset&#39;</span>
<span class="n">S3_CACHE_KEY_PREFIX</span> <span class="o">=</span> <span class="s1">&#39;sql_lab_result&#39;</span>
<span class="n">RESULTS_BACKEND</span> <span class="o">=</span> <span class="n">S3Cache</span><span class="p">(</span><span class="n">S3_CACHE_BUCKET</span><span class="p">,</span> <span class="n">S3_CACHE_KEY_PREFIX</span><span class="p">)</span>
<span class="c1"># On Redis</span>
<span class="kn">from</span> <span class="nn">werkzeug.contrib.cache</span> <span class="kn">import</span> <span class="n">RedisCache</span>
<span class="n">RESULTS_BACKEND</span> <span class="o">=</span> <span class="n">RedisCache</span><span class="p">(</span>
<span class="n">host</span><span class="o">=</span><span class="s1">&#39;localhost&#39;</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">6379</span><span class="p">,</span> <span class="n">key_prefix</span><span class="o">=</span><span class="s1">&#39;superset_results&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Also note that SQL Lab supports Jinja templating in queries, and that it&#8217;s
possible to overload
the default Jinja context in your environment by defining the
<code class="docutils literal"><span class="pre">JINJA_CONTEXT_ADDONS</span></code> in your superset configuration. Objects referenced
in this dictionary are made available for users to use in their SQL.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">JINJA_CONTEXT_ADDONS</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">&#39;my_crazy_macro&#39;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="o">*</span><span class="mi">2</span><span class="p">,</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="making-your-own-build">
<h2>Making your own build<a class="headerlink" href="#making-your-own-build" title="Permalink to this headline"></a></h2>
@@ -520,6 +597,29 @@ python setup.py install
</pre></div>
</div>
</div>
<div class="section" id="blueprints">
<h2>Blueprints<a class="headerlink" href="#blueprints" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="http://flask.pocoo.org/docs/0.12/blueprints/">Blueprints are Flask&#8217;s reusable apps</a>.
Superset allows you to specify an array of Blueprints
an array of Blueprints in your <code class="docutils literal"><span class="pre">superset_config</span></code> module. Here&#8217;s
an example on how this can work with a simple Blueprint. By doing
so, you can expect Superset to serve a page that says &#8220;OK&#8221;
at the <code class="docutils literal"><span class="pre">/simple_page</span></code> url. This can allow you to run other things such
as custom data visualization applications alongside Superset, on the
same server.</p>
<p>..code</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">flask</span> <span class="k">import</span> <span class="n">Blueprint</span>
<span class="n">simple_page</span> <span class="o">=</span> <span class="n">Blueprint</span><span class="p">(</span><span class="s1">&#39;simple_page&#39;</span><span class="p">,</span> <span class="n">__name__</span><span class="p">,</span>
<span class="n">template_folder</span><span class="o">=</span><span class="s1">&#39;templates&#39;</span><span class="p">)</span>
<span class="nd">@simple_page</span><span class="o">.</span><span class="n">route</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="n">defaults</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;page&#39;</span><span class="p">:</span> <span class="s1">&#39;index&#39;</span><span class="p">})</span>
<span class="nd">@simple_page</span><span class="o">.</span><span class="n">route</span><span class="p">(</span><span class="s1">&#39;/&lt;page&gt;&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">show</span><span class="p">(</span><span class="n">page</span><span class="p">):</span>
<span class="k">return</span> <span class="s2">&quot;Ok&quot;</span>
<span class="n">BLUEPRINTS</span> <span class="o">=</span> <span class="p">[</span><span class="n">simple_page</span><span class="p">]</span>
</pre></div>
</div>
</div>
</div>

Binary file not shown.

View File

@@ -117,7 +117,7 @@
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li></li>
<li>Search</li>
<li class="wy-breadcrumbs-aside">
</li>

File diff suppressed because one or more lines are too long

View File

@@ -89,6 +89,7 @@
<li class="toctree-l3"><a class="reference internal" href="#alpha">Alpha</a></li>
<li class="toctree-l3"><a class="reference internal" href="#gamma">Gamma</a></li>
<li class="toctree-l3"><a class="reference internal" href="#sql-lab">sql_lab</a></li>
<li class="toctree-l3"><a class="reference internal" href="#public">Public</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#managing-gamma-per-data-source-access">Managing Gamma per data source access</a></li>
@@ -194,6 +195,16 @@ they will only see the objects that they have access to.</p>
users have access to all databases by default, both <code class="docutils literal"><span class="pre">Alpha</span></code> and <code class="docutils literal"><span class="pre">Gamma</span></code>
users need to be given access on a per database basis.</p>
</div>
<div class="section" id="public">
<h3>Public<a class="headerlink" href="#public" title="Permalink to this headline"></a></h3>
<p>It&#8217;s possible to allow logged out users to access some Superset features.</p>
<p>By setting <code class="docutils literal"><span class="pre">PUBLIC_ROLE_LIKE_GAMMA</span> <span class="pre">=</span> <span class="pre">True</span></code> in your <code class="docutils literal"><span class="pre">superset_config.py</span></code>,
you grant public role the same set of permissions as for the GAMMA role.
This is useful if one wants to enable anonymous users to view
dashboards. Explicit grant on specific datasets is still required, meaning
that you need to edit the <code class="docutils literal"><span class="pre">Public</span></code> role and add the Public data sources
to the role manually.</p>
</div>
</div>
<div class="section" id="managing-gamma-per-data-source-access">
<h2>Managing Gamma per data source access<a class="headerlink" href="#managing-gamma-per-data-source-access" title="Permalink to this headline"></a></h2>

View File

@@ -202,62 +202,28 @@ Superset&#8217;s Jinja context:
<p><a class="reference external" href="http://jinja.pocoo.org/docs/dev/templates/">Jinja&#8217;s builtin filters</a> can be also be applied where needed.</p>
<dl class="class">
<dt id="superset.jinja_context.PrestoTemplateProcessor">
<em class="property">class </em><code class="descclassname">superset.jinja_context.</code><code class="descname">PrestoTemplateProcessor</code><span class="sig-paren">(</span><em>database=None</em>, <em>query=None</em>, <em>table=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/superset/jinja_context.html#PrestoTemplateProcessor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#superset.jinja_context.PrestoTemplateProcessor" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="descclassname">superset.jinja_context.</code><code class="descname">PrestoTemplateProcessor</code><span class="sig-paren">(</span><em>database=None</em>, <em>query=None</em>, <em>table=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/superset/jinja_context.html#PrestoTemplateProcessor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#superset.jinja_context.PrestoTemplateProcessor" title="Permalink to this definition"></a></dt>
<dd><p>Presto Jinja context</p>
<p>The methods described here are namespaced under <code class="docutils literal"><span class="pre">presto</span></code> in the
jinja context as in <code class="docutils literal"><span class="pre">SELECT</span> <span class="pre">'{{</span> <span class="pre">presto.some_macro_call()</span> <span class="pre">}}'</span></code></p>
<dl class="method">
<dt id="superset.jinja_context.PrestoTemplateProcessor.latest_partition">
<code class="descname">latest_partition</code><span class="sig-paren">(</span><em>table_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/superset/jinja_context.html#PrestoTemplateProcessor.latest_partition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#superset.jinja_context.PrestoTemplateProcessor.latest_partition" title="Permalink to this definition"></a></dt>
<dd><p>Returns the latest (max) partition value for a table</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>table_name</strong> (<em>str</em>) &#8211; the name of the table, can be just the table
name or a fully qualified table name as <code class="docutils literal"><span class="pre">schema_name.table_name</span></code></td>
</tr>
</tbody>
</table>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">latest_partition</span><span class="p">(</span><span class="s1">&#39;foo_table&#39;</span><span class="p">)</span>
<span class="go">&#39;2018-01-01&#39;</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="superset.jinja_context.PrestoTemplateProcessor.latest_sub_partition">
<code class="descname">latest_sub_partition</code><span class="sig-paren">(</span><em>table_name</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/superset/jinja_context.html#PrestoTemplateProcessor.latest_sub_partition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#superset.jinja_context.PrestoTemplateProcessor.latest_sub_partition" title="Permalink to this definition"></a></dt>
<dd><p>Returns the latest (max) partition value for a table</p>
<p>A filtering criteria should be passed for all fields that are
partitioned except for the field to be returned. For example,
if a table is partitioned by (<code class="docutils literal"><span class="pre">ds</span></code>, <code class="docutils literal"><span class="pre">event_type</span></code> and
<code class="docutils literal"><span class="pre">event_category</span></code>) and you want the latest <code class="docutils literal"><span class="pre">ds</span></code>, you&#8217;ll want
to provide a filter as keyword arguments for both
<code class="docutils literal"><span class="pre">event_type</span></code> and <code class="docutils literal"><span class="pre">event_category</span></code> as in
<a href="#id1"><span class="problematic" id="id2">``</span></a>latest_sub_partition(&#8216;my_table&#8217;,</p>
<blockquote>
<div>event_category=&#8217;page&#8217;, event_type=&#8217;click&#8217;)``</div></blockquote>
<dl class="function">
<dt id="superset.jinja_context.url_param">
<code class="descclassname">superset.jinja_context.</code><code class="descname">url_param</code><span class="sig-paren">(</span><em>param</em>, <em>default=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/superset/jinja_context.html#url_param"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#superset.jinja_context.url_param" title="Permalink to this definition"></a></dt>
<dd><p>Get a url paramater</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>table_name</strong> (<em>str</em>) &#8211; the name of the table, can be just the table
name or a fully qualified table name as <code class="docutils literal"><span class="pre">schema_name.table_name</span></code></li>
<li><strong>kwargs</strong> (<em>str</em>) &#8211; keyword arguments define the filtering criteria
on the partition list. There can be many of these.</li>
<li><strong>param</strong> (<em>str</em>) &#8211; the url parameter to lookup</li>
<li><strong>default</strong> (<em>str</em>) &#8211; the value to return in the absence of the parameter</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">latest_sub_partition</span><span class="p">(</span><span class="s1">&#39;sub_partition_table&#39;</span><span class="p">,</span> <span class="n">event_type</span><span class="o">=</span><span class="s1">&#39;click&#39;</span><span class="p">)</span>
<span class="go">&#39;2018-01-01&#39;</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
</div>

89
yarn.lock Normal file
View File

@@ -0,0 +1,89 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
asap@~2.0.3:
version "2.0.5"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f"
core-js@^1.0.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
encoding@^0.1.11:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
dependencies:
iconv-lite "~0.4.13"
fbjs@^0.8.9:
version "0.8.12"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04"
dependencies:
core-js "^1.0.0"
isomorphic-fetch "^2.1.1"
loose-envify "^1.0.0"
object-assign "^4.1.0"
promise "^7.1.1"
setimmediate "^1.0.5"
ua-parser-js "^0.7.9"
iconv-lite@~0.4.13:
version "0.4.15"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb"
is-stream@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
isomorphic-fetch@^2.1.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
dependencies:
node-fetch "^1.0.1"
whatwg-fetch ">=0.10.0"
js-tokens@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"
loose-envify@^1.0.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
js-tokens "^3.0.0"
node-fetch@^1.0.1:
version "1.6.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.6.3.tgz#dc234edd6489982d58e8f0db4f695029abcd8c04"
dependencies:
encoding "^0.1.11"
is-stream "^1.0.1"
object-assign@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
promise@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/promise/-/promise-7.1.1.tgz#489654c692616b8aa55b0724fa809bb7db49c5bf"
dependencies:
asap "~2.0.3"
react-test-renderer:
version "15.5.4"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-15.5.4.tgz#d4ebb23f613d685ea8f5390109c2d20fbf7c83bc"
dependencies:
fbjs "^0.8.9"
object-assign "^4.1.0"
setimmediate@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
ua-parser-js@^0.7.9:
version "0.7.12"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb"
whatwg-fetch@>=0.10.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"