| |
| |
| <!DOCTYPE html> |
| <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> |
| <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> |
| <head> |
| <meta charset="utf-8"> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <title>SQL Lab — Apache Superset documentation</title> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> |
| |
| |
| |
| |
| |
| <link rel="index" title="Index" |
| href="genindex.html"/> |
| <link rel="search" title="Search" href="search.html"/> |
| <link rel="top" title="Apache Superset documentation" href="index.html"/> |
| <link rel="next" title="Visualizations Gallery" href="gallery.html"/> |
| <link rel="prev" title="Security" href="security.html"/> |
| |
| |
| <script src="_static/js/modernizr.min.js"></script> |
| |
| </head> |
| |
| <body class="wy-body-for-nav" role="document"> |
| |
| |
| <div class="wy-grid-for-nav"> |
| |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search"> |
| |
| |
| |
| <a href="index.html" class="icon icon-home"> Apache Superset |
| |
| |
| |
| </a> |
| |
| |
| |
| |
| |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| |
| </div> |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| |
| |
| |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="installation.html">Installation & Configuration</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="tutorial.html">Tutorial - Creating your first dashboard</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="security.html">Security</a></li> |
| <li class="toctree-l1 current"><a class="current reference internal" href="#">SQL Lab</a><ul> |
| <li class="toctree-l2"><a class="reference internal" href="#feature-overview">Feature Overview</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="#extra-features">Extra features</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="#templating-with-jinja">Templating with Jinja</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#available-macros">Available macros</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#extending-macros">Extending macros</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="gallery.html">Visualizations Gallery</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="druid.html">Druid</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="misc.html">Misc</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> |
| |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="index.html">Apache Superset</a> |
| |
| </nav> |
| |
| |
| |
| <div class="wy-nav-content"> |
| <div class="rst-content"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| |
| <ul class="wy-breadcrumbs"> |
| |
| <li><a href="index.html">Docs</a> »</li> |
| |
| <li>SQL Lab</li> |
| |
| |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| |
| </li> |
| |
| </ul> |
| |
| |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="sql-lab"> |
| <h1>SQL Lab<a class="headerlink" href="#sql-lab" title="Permalink to this headline">¶</a></h1> |
| <p>SQL Lab is a modern, feature-rich SQL IDE written in |
| <a class="reference external" href="https://facebook.github.io/react/">React</a>.</p> |
| <hr class="docutils" /> |
| <img alt="_images/sqllab.png" src="_images/sqllab.png" /> |
| <hr class="docutils" /> |
| <div class="section" id="feature-overview"> |
| <h2>Feature Overview<a class="headerlink" href="#feature-overview" title="Permalink to this headline">¶</a></h2> |
| <ul class="simple"> |
| <li>Connects to just about any database backend</li> |
| <li>A multi-tab environment to work on multiple queries at a time</li> |
| <li>A smooth flow to visualize your query results using Superset’s rich |
| visualization capabilities</li> |
| <li>Browse database metadata: tables, columns, indexes, partitions</li> |
| <li>Support for long-running queries<ul> |
| <li>uses the <a class="reference external" href="http://www.python.org/">Celery distributed queue</a> |
| to dispatch query handling to workers</li> |
| <li>supports defining a “results backend” to persist query results</li> |
| </ul> |
| </li> |
| <li>A search engine to find queries executed in the past</li> |
| <li>Supports templating using the |
| <a class="reference external" href="http://jinja.pocoo.org/docs/dev/">Jinja templating language</a> |
| which allows for using macros in your SQL code</li> |
| </ul> |
| </div> |
| <div class="section" id="extra-features"> |
| <h2>Extra features<a class="headerlink" href="#extra-features" title="Permalink to this headline">¶</a></h2> |
| <ul class="simple"> |
| <li>Hit <code class="docutils literal"><span class="pre">alt</span> <span class="pre">+</span> <span class="pre">enter</span></code> as a keyboard shortcut to run your query</li> |
| </ul> |
| </div> |
| <div class="section" id="templating-with-jinja"> |
| <h2>Templating with Jinja<a class="headerlink" href="#templating-with-jinja" title="Permalink to this headline">¶</a></h2> |
| <div class="highlight-sql"><div class="highlight"><pre><span></span><span class="k">SELECT</span> <span class="o">*</span> |
| <span class="k">FROM</span> <span class="n">some_table</span> |
| <span class="k">WHERE</span> <span class="n">partition_key</span> <span class="o">=</span> <span class="s1">'{{ presto.latest_partition('</span><span class="n">some_table</span><span class="s1">') }}'</span> |
| </pre></div> |
| </div> |
| <p>Templating unleashes the power and capabilities of a |
| programming language within your SQL code.</p> |
| <p>Templates can also be used to write generic queries that are |
| parameterized so they can be re-used easily.</p> |
| <div class="section" id="available-macros"> |
| <h3>Available macros<a class="headerlink" href="#available-macros" title="Permalink to this headline">¶</a></h3> |
| <p>We expose certain modules from Python’s standard library in |
| Superset’s Jinja context:</p> |
| <ul class="simple"> |
| <li><code class="docutils literal"><span class="pre">time</span></code>: <code class="docutils literal"><span class="pre">time</span></code></li> |
| <li><code class="docutils literal"><span class="pre">datetime</span></code>: <code class="docutils literal"><span class="pre">datetime.datetime</span></code></li> |
| <li><code class="docutils literal"><span class="pre">uuid</span></code>: <code class="docutils literal"><span class="pre">uuid</span></code></li> |
| <li><code class="docutils literal"><span class="pre">random</span></code>: <code class="docutils literal"><span class="pre">random</span></code></li> |
| <li><code class="docutils literal"><span class="pre">relativedelta</span></code>: <code class="docutils literal"><span class="pre">dateutil.relativedelta.relativedelta</span></code></li> |
| </ul> |
| <p><a class="reference external" href="http://jinja.pocoo.org/docs/dev/templates/">Jinja’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>, <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> |
| </dd></dl> |
| |
| <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 or post data parameter</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>param</strong> (<em>str</em>) – the parameter to lookup</li> |
| <li><strong>default</strong> (<em>str</em>) – the value to return in the absence of the parameter</li> |
| </ul> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </dd></dl> |
| |
| </div> |
| <div class="section" id="extending-macros"> |
| <h3>Extending macros<a class="headerlink" href="#extending-macros" title="Permalink to this headline">¶</a></h3> |
| <p>As mentioned in the <a class="reference external" href="https://superset.incubator.apache.org/installation.html#installation-configuration">Installation & Configuration</a> documentation, |
| it’s possible for administrators to expose more more macros in their |
| environment using the configuration variable <code class="docutils literal"><span class="pre">JINJA_CONTEXT_ADDONS</span></code>. |
| All objects referenced in this dictionary will become available for users |
| to integrate in their queries in <strong>SQL Lab</strong>.</p> |
| </div> |
| </div> |
| </div> |
| |
| |
| </div> |
| <div class="articleComments"> |
| |
| </div> |
| </div> |
| <footer> |
| |
| <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| |
| <a href="gallery.html" class="btn btn-neutral float-right" title="Visualizations Gallery" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> |
| |
| |
| <a href="security.html" class="btn btn-neutral" title="Security" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> |
| |
| </div> |
| |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| |
| </p> |
| </div> |
| Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| |
| </footer> |
| |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| |
| |
| |
| |
| <script type="text/javascript"> |
| var DOCUMENTATION_OPTIONS = { |
| URL_ROOT:'./', |
| VERSION:'', |
| COLLAPSE_INDEX:false, |
| FILE_SUFFIX:'.html', |
| HAS_SOURCE: true, |
| SOURCELINK_SUFFIX: '.txt' |
| }; |
| </script> |
| <script type="text/javascript" src="_static/jquery.js"></script> |
| <script type="text/javascript" src="_static/underscore.js"></script> |
| <script type="text/javascript" src="_static/doctools.js"></script> |
| |
| |
| |
| |
| |
| <script type="text/javascript" src="_static/js/theme.js"></script> |
| |
| |
| |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.StickyNav.enable(); |
| }); |
| </script> |
| |
| |
| </body> |
| </html> |