Skip to content

Views

A View in AI/Code mode is a PostgreSQL query you write (or generate with AI assistance) directly in a SQL editor. The platform wraps it and, depending on the Result Type, may publish it as a callable PostgreSQL function available across the application.

Changes - whether applied from an AI suggestion or written manually - are saved to the view definition but do not take effect until you click Publish. Publishing is when the query is compiled, any PostgreSQL functions are created or updated, and the view becomes available to the rest of the application.


The AI/Code tab has two modes toggled with the See Code / Use AI button in the top right:

  • Use AI (default) - an AI chat panel for generating or refining the query in natural language.
  • See Code - the SQL editor for reading or writing the query directly.

Both modes share the same Sources, Input Params, and Palette controls in the toolbar at the top. These are not mode-specific: sources and params you add are available whether you are in the chat or the editor.


Sources define the entities, components, and views that the query is allowed to read from. You must add at least one source before the query can be published.

Click Sources in the toolbar to open the Sources panel. Each added source is listed as an expandable row showing its alias and columns. Use + Add to add another source.

When adding a source:

FieldDescription
Source TypeEntity, Component, View, or Query (an inline subquery)
Entity / Component / ViewThe specific target for the first three types
Source NameThe alias used to reference this source in SQL - auto-generated from the target name, editable
Status FilterLive or latest instances (default) or All statuses
Exclude Deleted RecordsCheckbox, on by default

Once added, a source’s alias is the name you reference in SQL. For example, a source aliased invoices is queried as SELECT i.total FROM invoices i. The alias is also the name shown in the Sources catalog in the Palette.


Input parameters are values passed into the view at query time - used for filtering, date ranges, or any value that should vary per call. Click Input Params in the toolbar to see and manage them.

FieldDescription
Parameter NameHuman-readable name
Parameter IDAuto-generated from the name; this is what you reference in SQL
Parameter TypeAny scalar type (Integer, Text, Date, etc.) or an entity/lookup type
Parameter DescriptionOptional free text
RequiredWhen unchecked, the parameter is optional and a default value applies
Value TypeValue - a fixed default literal; Expression - a SQL expression evaluated at query time (defaults to NULL)

When a parameter is not marked Required, you must set a default. The default Value Type is Expression with NULL - meaning if the caller omits the parameter, the query receives NULL.

Reference a parameter anywhere in the SQL using double curly braces around its Parameter ID:

{{param_id}}

For example, with a parameter named Year (ID: year, type: Integer):

WITH params AS (
SELECT
COALESCE({{year}}, EXTRACT(YEAR FROM CURRENT_DATE)::int) AS report_year,
make_date(COALESCE({{year}}, EXTRACT(YEAR FROM CURRENT_DATE)::int), 1, 1) AS ytd_start
)

The COALESCE pattern above is the typical way to handle an optional parameter - fall back to a computed default when the caller passes NULL.


The AI chat is the default view on the AI/Code tab. You can use it in two ways:

  • Questions and answers - ask the AI to explain the current query, describe what a function does, or clarify SQL behaviour.
  • Code generation - describe what the view should return and the AI writes the SQL. You can iterate: ask for changes, request additional columns, adjust filters, or refine joins in follow-up messages.

The AI is aware of your added sources and their columns - it will reference them correctly in generated SQL.

Applying suggestions: AI responses that include SQL appear as code blocks with Copy and Apply buttons. Clicking Apply pushes the SQL into the code editor. The AI never modifies the editor automatically - Apply is always an explicit action. Previous suggestions stay in the chat history and can be re-applied at any time if needed.


Click See Code to open the SQL editor directly. The same Sources, Input Params, and Palette toolbar links are available here. The editor supports standard PostgreSQL syntax including CTEs, window functions, subqueries, and any built-in PostgreSQL function.


The Palette is a command launcher available in code mode. Open it with F1 or by clicking Palette in the toolbar. It gives you searchable access to six catalogs - select any item to insert a reference or function call at the cursor position.

Lists all sources added to this view, and their individual columns with types. Selecting a source inserts its alias; selecting a column inserts alias.column_name. This is the fastest way to insert a correctly-named column reference without leaving the editor.

Lists all input parameters for this view with their types. Selecting one inserts the {{param_id}} placeholder syntax ready to use in the query.

Lists all views in the workspace that have been published as scalar functions (Result Type: Scalar value), grouped by application. Each entry shows the view’s display name and its fully qualified PostgreSQL function ID, for example:

SALES
Customer Credit Limit
sales.customer_credit_limit
FINANCE
Exchange Rate
finance.exchange_rate

Selecting an entry inserts the full function call with typed placeholders for every parameter:

finance.exchange_rate(<from_currency text>, <to_currency text>)

Replace each <name type> placeholder with a real value, column reference, or expression.

Lists views published as dataset functions (Result Type: Dataset with Create Dataset Function enabled), in the same grouped format. Selecting an entry inserts the function call with typed parameter placeholders. A dataset function is a set-returning function - it returns a table of rows and can be used in a FROM or JOIN clause.

The full built-in PostgreSQL function library. Selecting a function inserts its call signature with typed placeholders, the same way as the Anybuild function catalogs.

Reusable SQL snippets. Selecting a snippet inserts its content at the cursor.


The Result Type determines what shape the view returns and whether the platform publishes it as a callable PostgreSQL function.

There are three options:

Result TypeReturnsPublished as
Scalar valueA single valueA PostgreSQL scalar function, always
Single recordA single rowNot published as a function
DatasetA table of rowsA PostgreSQL set-returning function, when Create Dataset Function is checked

When Result Type is Scalar value, the platform always creates a PostgreSQL scalar function at publish time. The function’s fully qualified name follows the pattern:

<application_id>.<view_id>(param1, param2, ...)

For example, a view with ID exchange_rate in the finance application publishes as:

finance.exchange_rate(<from_currency text>, <to_currency text>)

This function becomes available:

  • In the Scalar SQL functions catalog in the Palette, callable from any other view’s SQL.
  • In every expression editor across the application - for example, as a Default Value expression on an entity field in the Data Model designer.
  • Directly in Database Workflow and Server Function code via the same <app_id>.<view_id>(...) call.

When Result Type is Single record, the view returns at most one row. It is not published as a PostgreSQL function - it can be used as a source in Design mode views but is not available in the Scalar or Dataset function catalogs.

When Result Type is Dataset, the view returns a table of rows. It can always be used as a source in other views (referenced in Design mode’s source picker or directly in SQL). To additionally publish it as a callable PostgreSQL function, check Create Dataset Function on the view’s detail screen.

When Create Dataset Function is enabled, the platform publishes a set-returning function using the same naming convention:

<application_id>.<view_id>(param1, param2, ...)

This function appears in the Dataset SQL functions catalog in the Palette and can be called in a FROM or JOIN clause anywhere SQL is written in the application:

SELECT *
FROM sales.open_orders({{customer_id}})