Skip to main content

SQL Gems

In Prophecy and dbt, data models are groups of SQL statements used to create a single table or view. Prophecy simplifies data modeling by visualizing the data model as a series of steps, each represented by a gem.

Each gem corresponds to a SQL statement, which users can construct through an intuitive visual interface. Prophecy handles the underlying complexity by deciding whether each gem should generate a CTE or a subquery. Users simply configure the gem's interface, and Prophecy integrates the resulting SQL into the larger data model.

The table below lists each gem available for data modeling.

CategoryDescription
AggregatePerforms aggregation operations on datasets, such as computing sums, averages, and counts.
DeduplicateRemoves duplicate records from a dataset to ensure data uniqueness and integrity.
ExceptExtract rows that are present in the first table but absent from all subsequent tables.
FilterFilters records in a dataset based on specified conditions, allowing for the selection of relevant data.
FlattenSchemaConverts nested or hierarchical data structures into a flat table format.
IntersectReturn only the rows that appear in all input tables.
JoinCombines two or more datasets based on a common key.
LimitRestricts the number of records in a dataset to a specified number.
MacroDefines reusable code snippets or functions that can be invoked across multiple models.
ModelsSequences of steps to perform SQL-based transformations that results in a single table.
OrderBySorts records in a dataset based on specified columns.
ReformatChanges the format or structure of data within a dataset, such as modifying date formats or string cases.
SeedProvides initial data to a pipeline or model, often used for testing or as reference data.
SQLStatementExecutes custom SQL statements within a pipeline or model, offering flexibility for complex transformations.
UnionCombine records from different sources.
WindowFunctionPerforms calculations across a set of table rows related to the current row (like running totals or moving averages).

What's next

To understand the generic structure of a gem, review the Gem concept page. To understand how to use visual expressions in SQL gems, visit Visual Gem Builder.