Chalk SQL
A SQL dialect for federated queries across everything in a Chalk environment.
Hover over a table or column to see its catalog details. The results drawer shows the sample output.
Chalk SQL is a dialect of SQL developed within Chalk built to create federated queries across a Chalk environment. Chalk SQL is a highly efficient, easy-to-write, and expressive language that enables:
Chalk SQL is distinct from .chalk.sql files. A .chalk.sql file defines a
SQL file resolver, which resolves features with a SQL query. A SQL file resolver’s query is written in Chalk SQL only when the file declares
source: chalksql, as described in Chalk SQL resolvers.
Use catalog.schema.table to name a table or view. The first part identifies
the catalog. For example, in my_postgres.public.users, my_postgres is the
registered data source name, public is the PostgreSQL schema, and users
is the table. Quote individual identifiers when they contain spaces or literal
dots, as in chalk.historical_values."user.name".
See Available tables for examples and ways to find tables in your environment.
Chalk SQL comprises three main components to both plan and run queries:
A custom-built transpiler from a dialect of SQL to Chalk’s internal planning system.
Chalk’s existing infrastructure to execute plans, which allows Chalk SQL to benefit from Native SQL drivers, static compilation of expressions, and integration with Velox, the open-source low-latency execution engine.
The Chalk Catalog, which is a culmination of various objects within a Chalk deployment. This includes features, resolvers, datasets, the online and offline store, and registered SQL sources.
A Chalk Catalog exists per deployment, meaning that as an environment changes over time through feature engineering, the Chalk Catalog will also update to reflect the newest changes. This means there’s no additional work to sync the catalog to pick up changes: if an additional resolver is added to a deployment, the Chalk Catalog will automatically know about it, and Chalk SQL can make queries against it.
Chalk SQL is automatically enabled and available for use in any environment that has at least one gRPC query server running. Both new and existing environments can start running Chalk SQL queries with no additional setup.
Chalk SQL is primarily run in three different contexts:
Run an ad hoc query in the SQL Explorer, from the CLI, or from Python
with ChalkGRPCClient.run_sql().
Use SQL as input to compute the input rows for a bulk online or offline feature query.
A .chalk.sql file resolver can declare source: chalksql, in which case its query is written in Chalk SQL and
compiled into the query plan rather than sent to an integration. See
Chalk SQL resolvers.