Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sqllab] add support for Jinja templating #1426

Merged
merged 5 commits into from
Oct 26, 2016

Conversation

mistercrunch
Copy link
Member

visualization capabilities
- Browse database metadata: tables, columns, indexes, partitions
- Support for long-running queries
- uses the Celery async framework to dispatch query handling to workers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we link to Celery docs here?

SQL Lab
=======

SQL Lab is a modern, feature-rich SQL IDE written in React.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we link to react docs here: https://facebook.github.io/react/

- uses the Celery async framework to dispatch query handling to workers
- supports defining a "result backend" to persist query results
- A search engine to find queries executed in the past
- Supports templating using the ``jinja`` templating language,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we link to jinja docs here?

Templating allows for getting the power and capabilities of a
programming language inside your SQL.

It also enables for writing generic queries as templates that can be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggested edit: Templates can also be used to write generic queries that are parameterized so they can be re-used easily.

knows about the database it is operating in.

This means that object methods are only available for the active database
and are given access the ``models.Database`` object and schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/given access the/given access to the

@ascott
Copy link
Contributor

ascott commented Oct 25, 2016

nice!! excited about templating for sql lab!! 🎉

part_field = indexes[0]['column_names'][0]
sql = self._partition_query(table_name, 1, [(part_field, True)])
df = self.database.get_df(sql, self.schema)
return df.to_records(index=False)[0][0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question: Why do these two functions look the same?

@@ -438,5 +438,11 @@ def test_extra_table_metadata(self):
'/caravel/extra_table_metadata/{dbid}/'
'ab_permission_view/panoramix/'.format(**locals()))

def test_process_template(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add test to the sql_lab tests demonstrating how it works end to end ?

def test_process_template(self):
sql = "SELECT '{{ datetime(2017, 1, 1).isoformat() }}'"
rendered = jinja_context.process_template(sql)
self.assertEqual("SELECT '2017-01-01T00:00:00'", rendered)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be great to have tests for all exposed modules, optional.

@bkyryliuk
Copy link
Member

Looks great!
:shipit:

zhaoyongjie added a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 17, 2021
zhaoyongjie added a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 24, 2021
zhaoyongjie added a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 25, 2021
zhaoyongjie added a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 26, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.12.0 labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants