Omniscope Custom Blocks › Inputs/Databases/Snowflake-custom-query

Snowflake Custom Query

Runs a SQL query on Snowflake, signing in with a password or a key pair, and outputs the result.

Inputs › Databases Python

Open the demo in Omniscope Download demo.ioz Sample data: placeholder.csv Source on GitHub

Omniscope custom block · Inputs

A Snowflake query whose result you need in a workflow? Run it from a short Python script, signed in with a password or a key pair, and get typed fields back.

Python · pandas, snowflake-connector-python · Snowflake connector installed on first run

The problem it solves

A team's numbers live in Snowflake, and the report needs a summary query: tickets per team per week, sales per region. Sometimes it helps to have that query in a small Python script beside the workflow, signed in with the service user's key pair, rather than in a database connection set up elsewhere.

This block runs the query and outputs its result.

How it works

What goes in

A Snowflake query

SELECT TEAM, WEEK_START, COUNT(*) AS TICKETS,
       ROUND(AVG(HOURS_TO_CLOSE), 2) AS AVG_HOURS_TO_CLOSE,
       MAX(UPDATED_AT) AS LAST_UPDATED
FROM SUPPORT.PUBLIC.TICKETS
WHERE WEEK_START >= '2026-02-02'
GROUP BY TEAM, WEEK_START
ORDER BY WEEK_START

Run against an invented support-tickets table.

The options

Option Demo setting What it does
Account identifier (yours) The account, from your Snowflake address.
User (yours) The user to sign in as.
Password, or Private key file and Private key password (yours) Password sign-in, or key-pair sign-in with a key file on the server.
Warehouse COMPUTE_WH Runs the query; empty for the user's default.
Database, Schema, Role SUPPORT, empty, empty Context for unqualified names; empty for the user's defaults.
SQL query the query above The query to run.

What comes out

Results (first rows)

TEAM WEEK_START TICKETS AVG_HOURS_TO_CLOSE LAST_UPDATED
Billing 2026-02-02 63 18.96 2026-02-02 17:10:00 UTC
Onboarding 2026-02-02 115 21.87 2026-02-02 16:11:00 UTC
Technical 2026-02-02 67 19.66 2026-02-02 22:12:00 UTC
Account changes 2026-02-02 39 29.46 2026-02-02 17:13:00 UTC

16 records. AVG_HOURS_TO_CLOSE is a decimal number (Snowflake NUMBER with 2 decimals); LAST_UPDATED came back with offsets +01:00 and -05:00 among others and is now all UTC (Technical's 17:12 at -05:00 is 22:12 UTC).

Where it pays off

Customer service: Weekly ticket summaries

Count tickets and time to close per team and week, and publish them as a service report.

Sales and finance: Summaries from the warehouse

Run the summary query in Snowflake and report only the totals.

Data teams: Service-user access

Sign in as a service user with a key pair where the account blocks password sign-in.

Prototyping: A query beside its Python

Keep a query and some Python post-processing together while the workflow takes shape.

Use cases describe typical scenarios and are illustrative; the sample data is invented.

Why do this in Omniscope

How it fits into an Omniscope workflow

Snowflake Custom Query (tickets per team and week) → Report (tickets by week, time to close by team)

Name tables in full (DATABASE.SCHEMA.TABLE) unless you set the database and schema.

Try it

  1. Open the demo project (demo.iox on the demo server, or import demo.ioz from this folder). It holds the block, not connected to any Snowflake account, and a File block with placeholder.csv: the block's output for the query above on invented data. The rest of the workflow runs from the File block.
  2. The question: which team takes longest to close tickets, and is it getting better?
  3. Look at the File block's output: 16 records, LAST_UPDATED in UTC.
  4. To query your own account: enter the account identifier, the user, a password or a private key file, and a query, and run it. Then connect it in place of the File block.

Running in Omniscope

Omniscope workflow
Omniscope workflow

The demo project's workflow: the block, its sample output in a File block, and a Validate data check on it.

Language and libraries

Python. It uses pandas and snowflake-connector-python.

pandas is part of Omniscope's Python environment. snowflake-connector-python (Apache License 2.0) is listed in the manifest's dependencies; Omniscope installs it on first run if it is missing.

Tested

The block is covered by automated tests that run its script against a stand-in for Omniscope's Python API and a stand-in for Snowflake's connector that returns the Python types the real one does (no call reaches Snowflake): the sample query and its connection settings, a failing query, an empty result, key-pair sign-in with schema and role, duplicate column names, TIME and all-missing fields, a statement with no result set, missing settings and a failed sign-in, and 200,000 rows.

Reference

Options

NameTypeWhat it does
Account identifierTextThe part of your Snowflake address before .snowflakecomputing.com, for example myorg-myaccount (or a locator such as xy12345.eu-west-1).
UserTextThe Snowflake user to sign in as.
PasswordPasswordThe user's password. Leave empty when signing in with a private key file.
Private key fileFileFor key-pair sign-in: the path, on the Omniscope server, of the user's private key (PEM, PKCS#8). Used instead of the password. Keep it outside any shared folder.
Private key passwordPasswordThe passphrase of an encrypted private key. Leave empty for an unencrypted key.
WarehouseTextOptional. The warehouse that runs the query, for example COMPUTE_WH. Empty: the user's default warehouse.
DatabaseTextOptional. The database for table names that don't name one, for example SALES. Empty: the user's default.
SchemaTextOptional. The schema for table names that don't name one, for example PUBLIC.
RoleTextOptional. The role to use, for example ANALYST. Empty: the user's default role.
SQL queryTextThe query to run, for example SELECT REGION, SUM(AMOUNT) AS AMOUNT FROM SALES.PUBLIC.ORDERS GROUP BY REGION.

Outputs

OutputWhat it holds
ResultsOne record per row the query returns, with the query's columns as fields.