Introducing a new way to review your PRs.

Read the announcement

getredash / redash

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.

View on GitHub

20 documents · Updated Nov 11, 2026

docs / query-runner-platform

Query runner platform

The query runner platform gives each data source one common way to accept a query and return tabular data. It hides connection and response differences across databases, SaaS APIs, files, HTTP services, and scripts so the wider query system can select a runner, execute work, inspect schema, and store results through the same boundary. See Querying and data source integration for the end-to-end query flow and Query results and serialization for result storage and delivery.

Runner contract

The runner contract is the shared boundary between a configured data source and query execution. A runner has a type and display name, exposes a configuration schema, accepts a query with the current user, and returns either result data or an error. The result uses a small set of column types so downstream systems do not need to understand each source's native types. References: redash/…/__init__.py• L50-58, redash/…/__init__.py• L127-139, redash/…/__init__.py• L232-249

Runners can provide capabilities beyond execution when the source supports them:

  • Connection checks validate a data source before use.
  • Schema discovery supplies tables or other queryable objects for the query editor.
  • Query annotation adds execution metadata where the source accepts comments. Only approved identifier and fixed-value metadata is added to SQL comments.
  • Auto-limit support protects SQL reads that do not set a row limit.
  • SSH tunnel support temporarily routes host-and-port connections through a bastion.

These capabilities are optional. The base contract reports unsupported schema or limit behavior rather than forcing every connector to pretend that it has the same features. References: redash/…/__init__.py• L203-232, redash/…/__init__.py• L251-282, redash/…/__init__.py• L511-545

Runner lifecycle

Runner selection starts with a data source type. At application start, the configured runner modules are imported. Each module registers its enabled runner class in a type-to-class catalog. Query execution then creates or uses the runner for that data source and sends the query through the common contract.

The following diagram shows how a data source moves from configuration to execution and result storage.

flowchart LR
    Settings[Runner settings] --> Import[Import enabled runner modules]
    Import --> Catalog[Runner catalog]
    DataSource[Configured data source] --> Select[Select runner by type]
    Catalog --> Select
    Query[Query text and user] --> Execute[Execute through runner]
    Select --> Execute
    Execute --> Outcome{Data or error}
    Outcome -->|data| Store[Store query result]
    Outcome -->|error| Failure[Report query failure]

The platform uses the runner's own query syntax. SQL runners receive SQL, while API, file, spreadsheet, and script runners interpret their query text in their own supported form. The execution worker adds metadata only when the runner allows query annotation. Refresh jobs apply a runner's auto-limit rule before they enqueue work. References: redash/…/__init__.py• L285-364, redash/__init__.py• L45-55, redash/…/execution.py• L197-250, redash/…/maintenance.py• L79-101

Connector catalog

The catalog groups connectors by the kind of source they adapt. The groups describe product capability rather than a list of every class. The active set is controlled by runner settings and can change when a required dependency is not installed or a runner is disabled.

Database connectors

Database connectors send source-language queries to relational, analytical, search, time-series, and graph systems. SQL connectors share SQL behavior such as schema discovery and safe automatic row limits when the source can support those operations. Non-SQL database connectors map their native query forms into the same rows-and-columns result shape.

The catalog includes connectors for the following database families:

  • Relational and SQL engines: PostgreSQL, Redshift, CockroachDB, MySQL, RDS MySQL, Microsoft SQL Server, SQL Server ODBC, SQLite, DuckDB, Oracle, DB2, Netezza, Vertica, Exasol, and RisingWave.
  • Cloud and analytical SQL engines: Amazon Athena, BigQuery, Databricks, Trino, Presto, Hive, Impala, ClickHouse, Tinybird, Pinot, Druid, Kylin, Drill, Snowflake, Databend, and E6Data.
  • Document, search, graph, and time-series systems: MongoDB, Couchbase, Elasticsearch, Amazon Elasticsearch, Cassandra, ArangoDB, Dgraph, InfluxDB, InfluxDB v2, Prometheus, Graphite, Apache Ignite, and Axibase TSDB.

Some entries are variants over a shared family. For example, Redshift and CockroachDB reuse PostgreSQL behavior, while Tinybird reuses ClickHouse behavior. Databricks uses token-authenticated SQL over an HTTP path and supports database and table metadata for editor browsing while leaving full generic schema discovery unsupported. It can apply a warehouse statement timeout and cap returned rows, while removing the changing job identifier from query annotations so repeated runs can use the source result cache. ArangoDB and Couchbase adapt non-relational query results into the common column and row shape. Exasol maps its native numeric and date values into the platform's supported types. References: redash/…/pg.py• L150-153, redash/…/pg.py• L306-331, redash/…/pg.py• L547-556, redash/…/tinybird.py• L1-11, redash/…/clickhouse.py• L1-20, redash/…/databricks.py• L62-111, redash/…/databricks.py• L125-174, redash/…/databricks.py• L176-224, redash/…/arango.py• L30-92, redash/…/couchbase.py• L37-71, redash/…/couchbase.py• L118-154, redash/…/exasol.py• L15-54, redash/…/exasol.py• L108-160

DuckDB provides an in-process SQL source for local or attached databases. It can load selected extensions and expose catalog-qualified tables for attached systems. Its data source settings also control external access, while local filesystem access remains blocked for query execution. References: redash/…/duckdb.py• L50-106, redash/…/duckdb.py• L108-170

SaaS and service connectors

SaaS connectors turn service-specific query requests into the shared result form. They handle the service's authentication, request model, pagination, and field or metric shape so users can query external platforms as data sources.

The service catalog includes Google Analytics 4, Google Search Console, Google Sheets, Salesforce, Jira JQL, Yandex Metrica, Yandex AppMetrica, Yandex Disk, Treasure Data, Uptycs, Azure Data Explorer through Kusto, CloudWatch, CloudWatch Insights, and Corporate Memory. A SPARQL endpoint connector provides the same kind of service boundary for semantic graph APIs. Google Sheets reads a selected worksheet and infers types from its values. Salesforce supports SOQL results with nested fields and service-reported field types. Corporate Memory and SPARQL endpoints expose graph query results with graph and prefix information for query authoring. References: redash/…/google_spreadsheets.py• L183-216, redash/…/google_spreadsheets.py• L237-260, redash/…/salesforce.py• L64-105, redash/…/salesforce.py• L165-203, redash/…/corporate_memory.py• L31-59, redash/…/corporate_memory.py• L148-179, redash/…/sparql_endpoint.py• L27-37, redash/…/sparql_endpoint.py• L119-154

File connectors

File connectors treat a remote file as a queryable source and convert its records into typed rows and columns. CSV and Excel use the same broad tabular model, while Google Sheets provides a worksheet-aware view of spreadsheet data. These connectors do not provide database schema discovery in the same way as SQL sources because the file or worksheet defines the available fields at read time.

The file-backed catalog includes CSV, Excel, Google Sheets, and Yandex Disk. CSV and Excel read tabular content from a URL. They infer common numeric, Boolean, date, time, and string types before returning the result. Google Sheets reads a selected worksheet and infers types from its values. References: redash/…/csv.py• L23-48, redash/…/csv.py• L61-115, redash/…/excel.py• L25-46, redash/…/excel.py• L61-113, redash/…/google_spreadsheets.py• L100-149

HTTP connectors

HTTP connectors turn web requests into query results. The shared HTTP runner supplies common URL handling, optional basic authentication, status checks, and protection against requests to private addresses. Connector-specific logic then defines the request syntax and response mapping.

The JSON connector accepts a YAML query that describes a GET or POST request. It can select a path in a nested response, select fields, and follow URL- or token-based pagination. When a base URL is configured, each resolved request must stay on the same origin. Prometheus accepts the service's query string and maps instant or range metrics to timestamp, value, and label fields. The URL connector returns raw response content and is retained as a deprecated generic endpoint connector.

References: redash/…/__init__.py• L353-428 redash/…/json_ds.py• L157-243 redash/…/json_ds.py• L246-302 redash/…/prometheus.py• L75-97 redash/…/prometheus.py• L180-210 redash/…/url.py• L5-35

Script connectors

Script connectors let a data source obtain query output from an executable command or from restricted Python code. The command runner maps query text to a configured script path and expects non-empty output. The Python runner executes code in a restricted environment and requires the code to produce a result object with rows and columns; it also provides helpers to read saved query results, inspect a source schema, and run another data source query subject to access checks.

Script-backed connectors are powerful but have different trust boundaries from ordinary read-only database connectors. The command runner has an explicit path policy and an option to invoke a shell. The Python runner limits built-ins and imports, but its query helpers can reach other data sources only for the current user's organization and access level.

References: redash/…/script.py• L7-27 redash/…/script.py• L30-75 redash/…/python.py• L72-115 redash/…/python.py• L213-291 redash/…/python.py• L312-391

Connector configuration

Each runner publishes a configuration schema for the data source setup surface. The schema describes the fields needed to connect or authenticate, marks sensitive values as secrets, and can expose source-specific options such as a database location, SSL mode, result reuse, or request behavior. Missing optional dependencies can disable a runner before it enters the catalog.

Configuration is therefore part of the runner contract. A data source type must remain aligned with its registered type, its schema, and the credentials or endpoint values that its runner reads. For example, PostgreSQL requires a database name and supports host, port, credentials, SSL, and extra connection parameters. BigQuery requires a project and can use either a supplied service account key or application default credentials. Databricks requires a host, HTTP path, and access token. It can also set a catalog, enable query annotation, and apply a statement timeout. DuckDB adds a database path, optional extensions, and an external-access setting that controls network and other external access without opening the local filesystem. References: redash/…/__init__.py• L203-205, redash/…/__init__.py• L269-275, redash/…/__init__.py• L362-383, redash/…/pg.py• L150-190, redash/…/big_query.py• L101-157, redash/…/databricks.py• L62-104, redash/…/duckdb.py• L60-82, redash/…/salesforce.py• L72-88, redash/…/sparql_endpoint.py• L157-172

Result boundary

Every successful runner adapts source output to a result with column metadata and row records. Column names must be unique within that result. The base runner renames duplicate names, while connector-specific parsers infer or map values to the platform's supported types. This common shape lets result storage, cached-query composition, alerts, visualizations, and APIs remain independent of the source protocol. The Databricks connector caps the returned rows at its result limit and marks the result as truncated when more rows remain. References: redash/…/__init__.py• L50-58, redash/…/__init__.py• L235-249, redash/…/execution.py• L230-263, redash/…/query_results.py• L125-143, redash/…/databricks.py• L137-174, redash/…/csv.py• L65-111, redash/…/excel.py• L64-110

The Query Results runner lets one query use saved, cached, or parameterized results from other queries as temporary tables. It checks organization and data-source access before loading a referenced query. Parameterized references pass through the shared parameter rules, and unsafe text parameters require full data-source access before the referenced query runs. References: redash/…/query_results.py• L46-107, redash/…/query_results.py• L150-218

Change checklist

When these files or sections are changed, remember to consider these:

  • A new or renamed runner must be present in the configured import list and must register a stable type used by data source records.
  • A configuration schema change must match the keys read by the runner and the secret fields shown to administrators.
  • A new result field or native type must map to the supported column types before serialization or visualization consumes it.
  • Changes to SQL auto-limit behavior must be checked against query hashing because the limited query text contributes to the cache identity.
  • Changes to HTTP or script access must preserve the platform's private-address and execution-path boundaries.
  • Changes to a runner's schema behavior must account for connectors that intentionally do not support schema discovery.
  • Changes to a connector's result cap must preserve the meaning of its truncation signal for consumers of query results.
  • Changes to SQL annotation metadata must preserve the allow-list so user-controlled text cannot enter query comments.
  • Changes to DuckDB external access must preserve local filesystem blocking and the locked connection settings.
  • Changes to JSON base URLs or pagination must preserve same-origin request checks and the unchanged-token loop guard.
  • Changes to Query Results parameter handling must preserve parameter validation and the stronger access check for unsafe parameters.
  • Changes to Databricks statement timeout or query annotation must preserve source-side cancellation and stable result-cache behavior.

Important failure modes

TriggerConsequenceGuard
Runner module is disabled or its dependency is missingThe data source type is not registered and cannot be selectedKeep dependency checks and enabled-runner settings aligned with supported deployments.
Data source type does not match a registered typeRunner lookup returns no runnerTreat the registered type as a stable data source contract.
Connector returns duplicate column namesRows can overwrite values when they are represented by nameUse the shared column normalization or an equivalent connector-specific rule.
SQL query has no limit and auto-limit is enabledA read can return more rows than the query surface expectsUse the SQL runner's limit check and preserve the limited text used for hashing.
Databricks statement timeout expiresThe warehouse cancels the statement and the query returns an errorSet the timeout in the data source configuration and handle the runner error.
Databricks returns more rows than its result capThe result is marked truncated and does not contain every source rowTreat the truncation flag as part of the result contract and set an appropriate source limit.
HTTP request targets a private address or returns a non-success statusQuery execution fails instead of exposing the responseUse the shared HTTP response path and its address checks.
JSON pagination resolves outside the configured base originThe query is rejected instead of sending the request to another originKeep base URL origin validation in the pagination path.
Paginated JSON token does not changeThe connector can loop over the same pageReject an unchanged pagination token.
DuckDB external access is enabled or a query tries to reset a restrictionExternal access may exceed the intended source boundary, or local file access may be attemptedSet the configured external-access mode, block the local filesystem, and lock the connection settings.
Script output is empty or Python result lacks rows or columnsThe query returns an execution error rather than usable dataTreat output shape validation as part of the connector contract.
Parameterized Query Results input is invalid or unsafe for the user's access levelA referenced query is rejected rather than running with unchecked valuesApply the shared parameter rules and require full data-source access for unsafe parameters.

Key files

FileWhy to read it
redash/…/__init__.pyDefines the shared runner contract, result types, registration catalog, SQL behavior, HTTP behavior, annotation boundary, and SSH tunnel boundary.
redash/…/__init__.pyShows the built-in connector catalog and how enabled, additional, and disabled runner modules are combined.
redash/__init__.pyShows when configured runner modules are imported during application startup.
redash/…/execution.pyShows how a selected runner receives a query and how successful data or errors affect query results.
redash/…/maintenance.pyShows where runner-specific SQL auto-limit behavior enters scheduled refresh.
redash/…/pg.pyIllustrates a relational connector with typed results, schema discovery, connection checks, and related variants.
redash/…/duckdb.pyIllustrates an in-process SQL connector with attached catalogs, optional extensions, and explicit filesystem and external-access boundaries.
redash/…/databricks.pyIllustrates an analytical SQL connector with token-based access, catalog-scoped browsing, statement timeout, query annotation, and bounded results.
redash/…/google_spreadsheets.pyIllustrates a SaaS and spreadsheet connector with worksheet selection and value type inference.
redash/…/csv.pyIllustrates a file connector that converts remote tabular content into the common result shape.
redash/…/python.pyIllustrates a restricted script connector with result validation and access-controlled query helpers.
redash/…/query_results.pyIllustrates the internal runner that composes saved, cached, and parameterized query results as temporary SQL tables with access checks.