Inverse Watch Docs
AppLanding
  • Overview
    • Home
    • Governance
      • Proposal 7
      • Proposal 25
      • Proposal 52
      • Proposal 107
      • Proposal 147 - S1
      • Proposal 189 - S2
  • Products
    • Inverse Alerts
      • See on Twitter
    • Inverse Chatbot
      • /doc
      • /imagine
      • /data
      • /graph
    • Inverse Subgraphs
      • See inverse-subgraph on Mainnet
      • See inverse-governance-subgraph on Mainnet
    • Inverse Watch
      • Go to App
  • User Guide
    • Quickstart
    • Alerts
      • Setting Up an Alert
      • Adding New Alert Destinations
      • Customize Alert Template
      • Multiple Column Alert
    • Queries
      • Creating and Editing Queries
      • Querying Existing Query Results
      • Query Parameters
      • How to Schedule a Query
      • Favorites & Tagging
      • Query Filters
      • How To Download / Export Query Results
      • Query Snippets
    • Visualizations
      • Cohort Visualizations
      • Visualizations How-To
      • Chart Visualizations
      • Formatting Numbers in Visualizations
      • How to Make a Pivot Table
      • Funnel Visualizations
      • Table Visualization Options
      • Visualizations Types
    • Dashboards
      • Creating and Editing Dashboards
      • Favorites & Tagging
      • Sharing and Embedding Dashboards
    • Data Sources
      • CSV & Excel Files
      • Google Sheets
      • JSON (API)
      • Python
      • EVM Chain Logs
      • EVM Chain State
      • GraphQL
      • Dune API
    • Machine Learning
      • Data Engineering
      • Regressors
        • Linear Regression
        • Random Forest
        • Ada Boosting
        • Gradient Boosting
        • Neural Network (LSTM)
      • Training and Predicting
      • Metrics & Overfitting
      • Examples
        • Price Prediction
          • Data Preprocessing
          • Model Creation & Training
          • Metrics Evaluation
          • Back Testing
          • Visualizing
        • Liquidation Risk
  • Admin & Dev Guide
    • Setup
    • Redash
    • Integrations & API
    • Query Runners
    • Users
      • Adding a Profile Picture
      • Authentication Options
      • Group Management
      • Inviting Users to Use Redash
      • Permissions & Groups
    • Visualizations
  • Cheat Sheets
    • Snippets
    • Contracts
  • More
    • Deprecated Apps
    • Github : inverse-flaskbot
    • Github : inverse-subgraph
    • Github : inverse-watch
Powered by GitBook
On this page
  • 1. Create A Query Snippet
  • 2. Insert A Query Snippet
  • 3. Insertion Points

Was this helpful?

  1. User Guide
  2. Queries

Query Snippets

PreviousHow To Download / Export Query ResultsNextVisualizations

Last updated 1 year ago

Was this helpful?

1. Create A Query Snippet

Copy and Paste are a big part of composing database queries. Because it’s much easier to duplicate prior work than to write it from scratch. This is particularly true for common JOIN statements or complex CASE expressions. As your list of queries in the application grows, however, it can be difficult to remember which queries contain the statement you need right now. Enter Query Snippets.

Query Snippets are segments of queries that your whole team can share and trigger via auto complete. You create them at Settings -> Query Snippets.

Here’s an example for a simple snippet:

JOIN organizations org ON org.id = ${1:table}.org_id

2. Insert A Query Snippet

If you have Live Auto Complete enabled, you can invoke your snippet from the Query Editor by typing the trigger word you defined in the Query Snippet editor. Auto Complete will suggest it like any other keyword in your database.

Here are some other ideas for snippets:

  • Frequent JOIN statements

  • Complicated clauses like WITH or CASE.

When the application renders the snippet, the dollar sign $ and curly braces {} will be stripped away and the word table will be highlighted for the user to replace.

When the application renders the snippet, the dollar sign $ and curly braces {} will be stripped away and the word table will be highlighted for the user to replace.

3. Insertion Points

In the example above, ${1:table} is an insertion point with placeholder text.

In the example above, ${1:table} is an insertion point with placeholder text.

You can use the placeholder text as a desirable default value for the user to override at runtime.

You designate insertion points by wrapping an integer tab order with a single dollar sign and curly braces ${}. A text placeholder preceded by a colon : is optional but useful for users unfamiliar with your snippet.

When the application renders this snippet:

AND (invoices.complete IS NULL OR invoices.complete <> '${2}')
AND (invoices.canceled IS NULL OR invoices.canceled <> '${1}')
AND (invoices.modified IS NULL OR invoices.modified_date <> '${0: this_date}')

The text insertion carat will jump to the second line between the quote marks ''. When the user presses Tab the carat will jump backwards onto the first line. When the user presses Tab again, the carat will jump to the third line and this_date will be highlighted to prompt the user for the desired value.

An insertion point of zero ${0} is always the last point in the tab order.

If Live Auto Complete is disabled, you can still invoke Query Snippets by pressing CTRL + Space and typing the trigger word for your Query Snippet. This can be necessary if your schema exceeds 5000 tokens.

Conditional Formatting
create a query snippets
insert a query snippet
create query snippets
query snippet insertion points